diff --git a/deps/v8/BUILD.gn b/deps/v8/BUILD.gn index 8895103222b4ee..55563f23adbbd2 100644 --- a/deps/v8/BUILD.gn +++ b/deps/v8/BUILD.gn @@ -887,7 +887,6 @@ v8_source_set("v8_base") { ### gcmole(all) ### "include/v8-debug.h", - "include/v8-experimental.h", "include/v8-platform.h", "include/v8-profiler.h", "include/v8-testing.h", @@ -905,8 +904,6 @@ v8_source_set("v8_base") { "src/api-arguments-inl.h", "src/api-arguments.cc", "src/api-arguments.h", - "src/api-experimental.cc", - "src/api-experimental.h", "src/api-natives.cc", "src/api-natives.h", "src/api.cc", @@ -1386,8 +1383,6 @@ v8_source_set("v8_base") { "src/external-reference-table.h", "src/factory.cc", "src/factory.h", - "src/fast-accessor-assembler.cc", - "src/fast-accessor-assembler.h", "src/fast-dtoa.cc", "src/fast-dtoa.h", "src/feedback-vector-inl.h", diff --git a/deps/v8/include/libplatform/libplatform.h b/deps/v8/include/libplatform/libplatform.h index cab467fd50704f..26baaa08667b4d 100644 --- a/deps/v8/include/libplatform/libplatform.h +++ b/deps/v8/include/libplatform/libplatform.h @@ -12,6 +12,8 @@ namespace v8 { namespace platform { +enum class IdleTaskSupport { kDisabled, kEnabled }; + /** * Returns a new instance of the default v8::Platform implementation. * @@ -21,7 +23,8 @@ namespace platform { * processors online will be chosen. */ V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform( - int thread_pool_size = 0); + int thread_pool_size = 0, + IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled); /** * Pumps the message loop for the given isolate. diff --git a/deps/v8/include/v8-experimental.h b/deps/v8/include/v8-experimental.h deleted file mode 100644 index 1773345e09add4..00000000000000 --- a/deps/v8/include/v8-experimental.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * This header contains a set of experimental V8 APIs. We hope these will - * become a part of standard V8, but they may also be removed if we deem the - * experiment to not be successul. - */ -#ifndef V8_INCLUDE_V8_EXPERIMENTAL_H_ -#define V8_INCLUDE_V8_EXPERIMENTAL_H_ - -#include "v8.h" // NOLINT(build/include) - -namespace v8 { -namespace experimental { - -// Allow the embedder to construct accessors that V8 can compile and use -// directly, without jumping into the runtime. -class V8_EXPORT FastAccessorBuilder { - public: - struct ValueId { - size_t value_id; - }; - struct LabelId { - size_t label_id; - }; - - static FastAccessorBuilder* New(Isolate* isolate); - - ValueId IntegerConstant(int int_constant); - ValueId GetReceiver(); - ValueId LoadInternalField(ValueId value_id, int field_no); - ValueId LoadInternalFieldUnchecked(ValueId value_id, int field_no); - ValueId LoadValue(ValueId value_id, int offset); - ValueId LoadObject(ValueId value_id, int offset); - ValueId ToSmi(ValueId value_id); - - void ReturnValue(ValueId value_id); - void CheckFlagSetOrReturnNull(ValueId value_id, int mask); - void CheckNotZeroOrReturnNull(ValueId value_id); - LabelId MakeLabel(); - void SetLabel(LabelId label_id); - void Goto(LabelId label_id); - void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); - ValueId Call(v8::FunctionCallback callback, ValueId value_id); - - private: - FastAccessorBuilder() = delete; - FastAccessorBuilder(const FastAccessorBuilder&) = delete; - ~FastAccessorBuilder() = delete; - void operator=(const FastAccessorBuilder&) = delete; -}; - -} // namespace experimental -} // namespace v8 - -#endif // V8_INCLUDE_V8_EXPERIMENTAL_H_ diff --git a/deps/v8/include/v8-profiler.h b/deps/v8/include/v8-profiler.h index f7d182f8021e1f..b60d137f4479e6 100644 --- a/deps/v8/include/v8-profiler.h +++ b/deps/v8/include/v8-profiler.h @@ -812,11 +812,6 @@ class V8_EXPORT HeapProfiler { /** Returns memory used for profiler internal data and snapshots. */ size_t GetProfilerMemorySize(); - /** - * Sets a RetainedObjectInfo for an object group (see V8::SetObjectGroupId). - */ - void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); - private: HeapProfiler(); ~HeapProfiler(); diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index baf44170f03d07..ae00eaa27fd985 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -127,7 +127,6 @@ template class PersistentValueVector; template class WeakCallbackObject; class FunctionTemplate; class ObjectTemplate; -class Data; template class FunctionCallbackInfo; template class PropertyCallbackInfo; class StackTrace; @@ -137,10 +136,6 @@ class CallHandlerHelper; class EscapableHandleScope; template class ReturnValue; -namespace experimental { -class FastAccessorBuilder; -} // namespace experimental - namespace internal { class Arguments; class Heap; @@ -155,30 +150,6 @@ class GlobalHandles; } // namespace internal -/** - * General purpose unique identifier. - */ -class UniqueId { - public: - explicit UniqueId(intptr_t data) - : data_(data) {} - - bool operator==(const UniqueId& other) const { - return data_ == other.data_; - } - - bool operator!=(const UniqueId& other) const { - return data_ != other.data_; - } - - bool operator<(const UniqueId& other) const { - return data_ < other.data_; - } - - private: - intptr_t data_; -}; - // --- Handles --- #define TYPE_CHECK(T, S) \ @@ -388,19 +359,18 @@ class MaybeLocal { // Eternal handles are set-once handles that live for the life of the isolate. template class Eternal { public: - V8_INLINE Eternal() : index_(kInitialValue) { } - template - V8_INLINE Eternal(Isolate* isolate, Local handle) : index_(kInitialValue) { + V8_INLINE Eternal() : val_(nullptr) {} + template + V8_INLINE Eternal(Isolate* isolate, Local handle) : val_(nullptr) { Set(isolate, handle); } // Can only be safely called if already set. - V8_INLINE Local Get(Isolate* isolate); - V8_INLINE bool IsEmpty() { return index_ == kInitialValue; } + V8_INLINE Local Get(Isolate* isolate) const; + V8_INLINE bool IsEmpty() const { return val_ == nullptr; } template V8_INLINE void Set(Isolate* isolate, Local handle); private: - static const int kInitialValue = -1; - int index_; + T* val_; }; @@ -1922,7 +1892,7 @@ class V8_EXPORT NativeWeakMap : public Data { public: static Local New(Isolate* isolate); void Set(Local key, Local value); - Local Get(Local key); + Local Get(Local key) const; bool Has(Local key); bool Delete(Local key); }; @@ -5122,16 +5092,6 @@ class V8_EXPORT FunctionTemplate : public Template { static MaybeLocal FromSnapshot(Isolate* isolate, size_t index); - /** - * Creates a function template with a fast handler. If a fast handler is set, - * the callback cannot be null. - */ - static Local NewWithFastHandler( - Isolate* isolate, FunctionCallback callback, - experimental::FastAccessorBuilder* fast_handler = nullptr, - Local data = Local(), - Local signature = Local(), int length = 0); - /** * Creates a function template backed/cached by a private property. */ @@ -5159,9 +5119,8 @@ class V8_EXPORT FunctionTemplate : public Template { * callback is called whenever the function created from this * FunctionTemplate is called. */ - void SetCallHandler( - FunctionCallback callback, Local data = Local(), - experimental::FastAccessorBuilder* fast_handler = nullptr); + void SetCallHandler(FunctionCallback callback, + Local data = Local()); /** Set the predefined length property for the FunctionTemplate. */ void SetLength(int length); @@ -6824,45 +6783,6 @@ class V8_EXPORT Isolate { */ Local ThrowException(Local exception); - /** - * Allows the host application to group objects together. If one - * object in the group is alive, all objects in the group are alive. - * After each garbage collection, object groups are removed. It is - * intended to be used in the before-garbage-collection callback - * function, for instance to simulate DOM tree connections among JS - * wrapper objects. Object groups for all dependent handles need to - * be provided for kGCTypeMarkSweepCompact collections, for all other - * garbage collection types it is sufficient to provide object groups - * for partially dependent handles only. - */ - template - V8_DEPRECATED("Use EmbedderHeapTracer", - void SetObjectGroupId(const Persistent& object, - UniqueId id)); - - /** - * Allows the host application to declare implicit references from an object - * group to an object. If the objects of the object group are alive, the child - * object is alive too. After each garbage collection, all implicit references - * are removed. It is intended to be used in the before-garbage-collection - * callback function. - */ - template - V8_DEPRECATED("Use EmbedderHeapTracer", - void SetReferenceFromGroup(UniqueId id, - const Persistent& child)); - - /** - * Allows the host application to declare implicit references from an object - * to another object. If the parent object is alive, the child object is alive - * too. After each garbage collection, all implicit references are removed. It - * is intended to be used in the before-garbage-collection callback function. - */ - template - V8_DEPRECATED("Use EmbedderHeapTracer", - void SetReference(const Persistent& parent, - const Persistent& child)); - typedef void (*GCCallback)(Isolate* isolate, GCType type, GCCallbackFlags flags); @@ -7223,16 +7143,6 @@ class V8_EXPORT Isolate { void SetAllowCodeGenerationFromStringsCallback( AllowCodeGenerationFromStringsCallback callback); - /** - * Set the callback to invoke to check if wasm compilation from - * the specified object is allowed. By default, wasm compilation - * is allowed. - * - * Similar for instantiate. - */ - void SetAllowWasmCompileCallback(AllowWasmCompileCallback callback); - void SetAllowWasmInstantiateCallback(AllowWasmInstantiateCallback callback); - /** * Check if V8 is dead and therefore unusable. This is the case after * fatal errors such as out-of-memory situations. @@ -7328,9 +7238,6 @@ class V8_EXPORT Isolate { template friend class PersistentValueMapBase; - void SetObjectGroupId(internal::Object** object, UniqueId id); - void SetReferenceFromGroup(UniqueId id, internal::Object** object); - void SetReference(internal::Object** parent, internal::Object** child); void ReportExternalAllocationLimitReached(); }; @@ -7709,10 +7616,7 @@ class V8_EXPORT V8 { WeakCallbackInfo::Callback weak_callback); static void MakeWeak(internal::Object*** location_addr); static void* ClearWeak(internal::Object** location); - static void Eternalize(Isolate* isolate, - Value* handle, - int* index); - static Local GetEternal(Isolate* isolate, int index); + static Value* Eternalize(Isolate* isolate, Value* handle); static void RegisterExternallyReferencedObject(internal::Object** object, internal::Isolate* isolate); @@ -8531,8 +8435,8 @@ class Internals { static const int kNodeIsIndependentShift = 3; static const int kNodeIsActiveShift = 4; - static const int kJSApiObjectType = 0xb9; - static const int kJSObjectType = 0xba; + static const int kJSApiObjectType = 0xbb; + static const int kJSObjectType = 0xbc; static const int kFirstNonstringType = 0x80; static const int kOddballType = 0x82; static const int kForeignType = 0x86; @@ -8677,13 +8581,15 @@ template template void Eternal::Set(Isolate* isolate, Local handle) { TYPE_CHECK(T, S); - V8::Eternalize(isolate, reinterpret_cast(*handle), &this->index_); + val_ = reinterpret_cast( + V8::Eternalize(isolate, reinterpret_cast(*handle))); } - -template -Local Eternal::Get(Isolate* isolate) { - return Local(reinterpret_cast(*V8::GetEternal(isolate, index_))); +template +Local Eternal::Get(Isolate* isolate) const { + // The eternal handle will never go away, so as with the roots, we don't even + // need to open a handle. + return Local(val_); } @@ -9740,33 +9646,6 @@ int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( return *external_memory; } - -template -void Isolate::SetObjectGroupId(const Persistent& object, - UniqueId id) { - TYPE_CHECK(Value, T); - SetObjectGroupId(reinterpret_cast(object.val_), id); -} - - -template -void Isolate::SetReferenceFromGroup(UniqueId id, - const Persistent& object) { - TYPE_CHECK(Value, T); - SetReferenceFromGroup(id, reinterpret_cast(object.val_)); -} - - -template -void Isolate::SetReference(const Persistent& parent, - const Persistent& child) { - TYPE_CHECK(Object, T); - TYPE_CHECK(Value, S); - SetReference(reinterpret_cast(parent.val_), - reinterpret_cast(child.val_)); -} - - Local Context::GetEmbedderData(int index) { #ifndef V8_ENABLE_CHECKS typedef internal::Object O; diff --git a/deps/v8/src/api-experimental.cc b/deps/v8/src/api-experimental.cc deleted file mode 100644 index a9b5bd043b8997..00000000000000 --- a/deps/v8/src/api-experimental.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * Implementation for v8-experimental.h. - */ - -#include "src/api-experimental.h" - -#include "include/v8-experimental.h" -#include "include/v8.h" -#include "src/api.h" -#include "src/fast-accessor-assembler.h" -#include "src/objects-inl.h" - -namespace { - -v8::internal::FastAccessorAssembler* FromApi( - v8::experimental::FastAccessorBuilder* builder) { - return reinterpret_cast(builder); -} - -v8::experimental::FastAccessorBuilder* FromInternal( - v8::internal::FastAccessorAssembler* fast_accessor_assembler) { - return reinterpret_cast( - fast_accessor_assembler); -} - -} // namespace - -namespace v8 { -namespace internal { -namespace experimental { - - -MaybeHandle BuildCodeFromFastAccessorBuilder( - v8::experimental::FastAccessorBuilder* fast_handler) { - i::MaybeHandle code; - if (fast_handler != nullptr) { - auto faa = FromApi(fast_handler); - code = faa->Build(); - CHECK(!code.is_null()); - delete faa; - } - return code; -} - -} // namespace experimental -} // namespace internal - - -namespace experimental { - - -FastAccessorBuilder* FastAccessorBuilder::New(Isolate* isolate) { - i::Isolate* i_isolate = reinterpret_cast(isolate); - internal::FastAccessorAssembler* faa = - new internal::FastAccessorAssembler(i_isolate); - return FromInternal(faa); -} - - -FastAccessorBuilder::ValueId FastAccessorBuilder::IntegerConstant( - int const_value) { - return FromApi(this)->IntegerConstant(const_value); -} - - -FastAccessorBuilder::ValueId FastAccessorBuilder::GetReceiver() { - return FromApi(this)->GetReceiver(); -} - - -FastAccessorBuilder::ValueId FastAccessorBuilder::LoadInternalField( - ValueId value, int field_no) { - return FromApi(this)->LoadInternalField(value, field_no); -} - -FastAccessorBuilder::ValueId FastAccessorBuilder::LoadInternalFieldUnchecked( - ValueId value, int field_no) { - return FromApi(this)->LoadInternalFieldUnchecked(value, field_no); -} - -FastAccessorBuilder::ValueId FastAccessorBuilder::LoadValue(ValueId value_id, - int offset) { - return FromApi(this)->LoadValue(value_id, offset); -} - - -FastAccessorBuilder::ValueId FastAccessorBuilder::LoadObject(ValueId value_id, - int offset) { - return FromApi(this)->LoadObject(value_id, offset); -} - -FastAccessorBuilder::ValueId FastAccessorBuilder::ToSmi(ValueId value_id) { - return FromApi(this)->ToSmi(value_id); -} - -void FastAccessorBuilder::ReturnValue(ValueId value) { - FromApi(this)->ReturnValue(value); -} - - -void FastAccessorBuilder::CheckFlagSetOrReturnNull(ValueId value_id, int mask) { - FromApi(this)->CheckFlagSetOrReturnNull(value_id, mask); -} - - -void FastAccessorBuilder::CheckNotZeroOrReturnNull(ValueId value_id) { - FromApi(this)->CheckNotZeroOrReturnNull(value_id); -} - - -FastAccessorBuilder::LabelId FastAccessorBuilder::MakeLabel() { - return FromApi(this)->MakeLabel(); -} - - -void FastAccessorBuilder::SetLabel(LabelId label_id) { - FromApi(this)->SetLabel(label_id); -} - -void FastAccessorBuilder::Goto(LabelId label_id) { - FromApi(this)->Goto(label_id); -} - -void FastAccessorBuilder::CheckNotZeroOrJump(ValueId value_id, - LabelId label_id) { - FromApi(this)->CheckNotZeroOrJump(value_id, label_id); -} - -FastAccessorBuilder::ValueId FastAccessorBuilder::Call( - v8::FunctionCallback callback, ValueId value_id) { - return FromApi(this)->Call(callback, value_id); -} - -} // namespace experimental -} // namespace v8 diff --git a/deps/v8/src/api-experimental.h b/deps/v8/src/api-experimental.h deleted file mode 100644 index 5b1bc1b04a2b18..00000000000000 --- a/deps/v8/src/api-experimental.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_API_EXPERIMENTAL_H_ -#define V8_API_EXPERIMENTAL_H_ - -namespace v8 { -namespace internal { -class Code; -template -class MaybeHandle; -} // internal; -namespace experimental { -class FastAccessorBuilder; -} // experimental - -namespace internal { -namespace experimental { - -v8::internal::MaybeHandle BuildCodeFromFastAccessorBuilder( - v8::experimental::FastAccessorBuilder* fast_handler); - -} // namespace experimental -} // namespace internal -} // namespace v8 - -#endif // V8_API_EXPERIMENTAL_H_ diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index beefd61bdb6b9d..c6cfd6ba997978 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -12,12 +12,10 @@ #include #include #include "include/v8-debug.h" -#include "include/v8-experimental.h" #include "include/v8-profiler.h" #include "include/v8-testing.h" #include "include/v8-util.h" #include "src/accessors.h" -#include "src/api-experimental.h" #include "src/api-natives.h" #include "src/assert-scope.h" #include "src/background-parsing-task.h" @@ -938,17 +936,13 @@ void V8::DisposeGlobal(i::Object** location) { i::GlobalHandles::Destroy(location); } - -void V8::Eternalize(Isolate* v8_isolate, Value* value, int* index) { +Value* V8::Eternalize(Isolate* v8_isolate, Value* value) { i::Isolate* isolate = reinterpret_cast(v8_isolate); i::Object* object = *Utils::OpenHandle(value); - isolate->eternal_handles()->Create(isolate, object, index); -} - - -Local V8::GetEternal(Isolate* v8_isolate, int index) { - i::Isolate* isolate = reinterpret_cast(v8_isolate); - return Utils::ToLocal(isolate->eternal_handles()->Get(index)); + int index = -1; + isolate->eternal_handles()->Create(isolate, object, &index); + return reinterpret_cast( + isolate->eternal_handles()->Get(index).location()); } @@ -1286,8 +1280,7 @@ void FunctionTemplate::Inherit(v8::Local value) { } static Local FunctionTemplateNew( - i::Isolate* isolate, FunctionCallback callback, - experimental::FastAccessorBuilder* fast_handler, v8::Local data, + i::Isolate* isolate, FunctionCallback callback, v8::Local data, v8::Local signature, int length, bool do_not_cache, v8::Local cached_property_name = v8::Local()) { i::Handle struct_obj = @@ -1305,7 +1298,7 @@ static Local FunctionTemplateNew( if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(isolate)); } - Utils::ToLocal(obj)->SetCallHandler(callback, data, fast_handler); + Utils::ToLocal(obj)->SetCallHandler(callback, data); } obj->set_length(length); obj->set_undetectable(false); @@ -1328,8 +1321,8 @@ Local FunctionTemplate::New( // function templates when the isolate is created for serialization. LOG_API(i_isolate, FunctionTemplate, New); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - auto templ = FunctionTemplateNew(i_isolate, callback, nullptr, data, - signature, length, false); + auto templ = + FunctionTemplateNew(i_isolate, callback, data, signature, length, false); if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); return templ; } @@ -1349,25 +1342,14 @@ MaybeLocal FunctionTemplate::FromSnapshot(Isolate* isolate, return Local(); } -Local FunctionTemplate::NewWithFastHandler( - Isolate* isolate, FunctionCallback callback, - experimental::FastAccessorBuilder* fast_handler, v8::Local data, - v8::Local signature, int length) { - i::Isolate* i_isolate = reinterpret_cast(isolate); - LOG_API(i_isolate, FunctionTemplate, NewWithFastHandler); - ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - return FunctionTemplateNew(i_isolate, callback, fast_handler, data, signature, - length, false); -} - Local FunctionTemplate::NewWithCache( Isolate* isolate, FunctionCallback callback, Local cache_property, Local data, Local signature, int length) { i::Isolate* i_isolate = reinterpret_cast(isolate); LOG_API(i_isolate, FunctionTemplate, NewWithCache); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate); - return FunctionTemplateNew(i_isolate, callback, nullptr, data, signature, - length, false, cache_property); + return FunctionTemplateNew(i_isolate, callback, data, signature, length, + false, cache_property); } Local Signature::New(Isolate* isolate, @@ -1387,10 +1369,8 @@ Local AccessorSignature::New( (obj)->setter(*foreign); \ } while (false) - -void FunctionTemplate::SetCallHandler( - FunctionCallback callback, v8::Local data, - experimental::FastAccessorBuilder* fast_handler) { +void FunctionTemplate::SetCallHandler(FunctionCallback callback, + v8::Local data) { auto info = Utils::OpenHandle(this); EnsureNotInstantiated(info, "v8::FunctionTemplate::SetCallHandler"); i::Isolate* isolate = info->GetIsolate(); @@ -1401,11 +1381,6 @@ void FunctionTemplate::SetCallHandler( i::Handle obj = i::Handle::cast(struct_obj); SET_FIELD_WRAPPED(obj, set_callback, callback); - i::MaybeHandle code = - i::experimental::BuildCodeFromFastAccessorBuilder(fast_handler); - if (!code.is_null()) { - obj->set_fast_handler(*code.ToHandleChecked()); - } if (data.IsEmpty()) { data = v8::Undefined(reinterpret_cast(isolate)); } @@ -2998,8 +2973,7 @@ void NativeWeakMap::Set(Local v8_key, Local v8_value) { i::JSWeakCollection::Set(weak_collection, key, value, hash); } - -Local NativeWeakMap::Get(Local v8_key) { +Local NativeWeakMap::Get(Local v8_key) const { i::Handle weak_collection = Utils::OpenHandle(this); i::Isolate* isolate = weak_collection->GetIsolate(); ENTER_V8(isolate); @@ -5078,8 +5052,8 @@ MaybeLocal Function::New(Local context, i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); LOG_API(isolate, Function, New); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); - auto templ = FunctionTemplateNew(isolate, callback, nullptr, data, - Local(), length, true); + auto templ = FunctionTemplateNew(isolate, callback, data, Local(), + length, true); if (behavior == ConstructorBehavior::kThrow) templ->RemovePrototype(); return templ->GetFunction(context); } @@ -8056,31 +8030,6 @@ v8::Local Isolate::ThrowException(v8::Local value) { return v8::Undefined(reinterpret_cast(isolate)); } - -void Isolate::SetObjectGroupId(internal::Object** object, UniqueId id) { - i::Isolate* internal_isolate = reinterpret_cast(this); - internal_isolate->global_handles()->SetObjectGroupId( - i::Handle(object).location(), id); -} - - -void Isolate::SetReferenceFromGroup(UniqueId id, internal::Object** object) { - i::Isolate* internal_isolate = reinterpret_cast(this); - internal_isolate->global_handles()->SetReferenceFromGroup( - id, i::Handle(object).location()); -} - - -void Isolate::SetReference(internal::Object** parent, - internal::Object** child) { - i::Isolate* internal_isolate = reinterpret_cast(this); - i::Object** parent_location = i::Handle(parent).location(); - internal_isolate->global_handles()->SetReference( - reinterpret_cast(parent_location), - i::Handle(child).location()); -} - - void Isolate::AddGCPrologueCallback(GCCallback callback, GCType gc_type) { i::Isolate* isolate = reinterpret_cast(this); isolate->heap()->AddGCPrologueCallback(callback, gc_type); @@ -8691,17 +8640,6 @@ void Isolate::SetAllowCodeGenerationFromStringsCallback( isolate->set_allow_code_gen_callback(callback); } -void Isolate::SetAllowWasmCompileCallback(AllowWasmCompileCallback callback) { - i::Isolate* isolate = reinterpret_cast(this); - isolate->set_allow_wasm_compile_callback(callback); -} - -void Isolate::SetAllowWasmInstantiateCallback( - AllowWasmInstantiateCallback callback) { - i::Isolate* isolate = reinterpret_cast(this); - isolate->set_allow_wasm_instantiate_callback(callback); -} - bool Isolate::IsDead() { i::Isolate* isolate = reinterpret_cast(this); return isolate->IsDead(); @@ -10025,13 +9963,6 @@ size_t HeapProfiler::GetProfilerMemorySize() { GetMemorySizeUsedByProfiler(); } - -void HeapProfiler::SetRetainedObjectInfo(UniqueId id, - RetainedObjectInfo* info) { - reinterpret_cast(this)->SetRetainedObjectInfo(id, info); -} - - v8::Testing::StressType internal::Testing::stress_type_ = v8::Testing::kStressTypeOpt; diff --git a/deps/v8/src/builtins/arm/builtins-arm.cc b/deps/v8/src/builtins/arm/builtins-arm.cc index 2d03783d1122ea..cfaa8626f184e2 100644 --- a/deps/v8/src/builtins/arm/builtins-arm.cc +++ b/deps/v8/src/builtins/arm/builtins-arm.cc @@ -1710,104 +1710,6 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); } -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Register scratch0, Register scratch1, - Register scratch2, - Label* receiver_check_failed) { - Register signature = scratch0; - Register map = scratch1; - Register constructor = scratch2; - - // If there is no signature, return the holder. - __ ldr(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - __ CompareRoot(signature, Heap::kUndefinedValueRootIndex); - Label receiver_check_passed; - __ b(eq, &receiver_check_passed); - - // Walk the prototype chain. - __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, ip, ip); - __ cmp(ip, Operand(JS_FUNCTION_TYPE)); - Label next_prototype; - __ b(ne, &next_prototype); - Register type = constructor; - __ ldr(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ ldr(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ cmp(signature, type); - __ b(eq, &receiver_check_passed); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ CompareObjectType(type, ip, ip, FUNCTION_TEMPLATE_INFO_TYPE); - - // Otherwise load the parent function template and iterate. - __ ldr(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset), - eq); - __ b(&function_template_loop, eq); - - // Load the next prototype. - __ bind(&next_prototype); - __ ldr(ip, FieldMemOperand(map, Map::kBitField3Offset)); - __ tst(ip, Operand(Map::HasHiddenPrototype::kMask)); - __ b(eq, receiver_check_failed); - __ ldr(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ b(&prototype_loop_start); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- r0 : number of arguments excluding receiver - // -- r1 : callee - // -- lr : return address - // -- sp[0] : last argument - // -- ... - // -- sp[4 * (argc - 1)] : first argument - // -- sp[4 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ ldr(r3, FieldMemOperand(r1, JSFunction::kSharedFunctionInfoOffset)); - __ ldr(r3, FieldMemOperand(r3, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ ldr(r2, MemOperand(sp, r0, LSL, kPointerSizeLog2)); - CompatibleReceiverCheck(masm, r2, r3, r4, r5, r6, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ ldr(r4, FieldMemOperand(r3, FunctionTemplateInfo::kCallCodeOffset)); - __ ldr(r4, FieldMemOperand(r4, CallHandlerInfo::kFastHandlerOffset)); - __ add(r4, r4, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ Jump(r4); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - // Drop the arguments (including the receiver) - __ add(r0, r0, Operand(1)); - __ add(sp, sp, Operand(r0, LSL, kPointerSizeLog2)); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/arm64/builtins-arm64.cc b/deps/v8/src/builtins/arm64/builtins-arm64.cc index 74e6c701332cdb..7d00f0827bd0bc 100644 --- a/deps/v8/src/builtins/arm64/builtins-arm64.cc +++ b/deps/v8/src/builtins/arm64/builtins-arm64.cc @@ -1715,104 +1715,6 @@ void Builtins::Generate_NotifySoftDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::SOFT); } -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Register scratch0, Register scratch1, - Register scratch2, - Label* receiver_check_failed) { - Register signature = scratch0; - Register map = scratch1; - Register constructor = scratch2; - - // If there is no signature, return the holder. - __ Ldr(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - __ CompareRoot(signature, Heap::kUndefinedValueRootIndex); - Label receiver_check_passed; - __ B(eq, &receiver_check_passed); - - // Walk the prototype chain. - __ Ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ Bind(&prototype_loop_start); - - // Get the constructor, if any - __ GetMapConstructor(constructor, map, x16, x16); - __ cmp(x16, Operand(JS_FUNCTION_TYPE)); - Label next_prototype; - __ B(ne, &next_prototype); - Register type = constructor; - __ Ldr(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ Ldr(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ Bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ Cmp(signature, type); - __ B(eq, &receiver_check_passed); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ CompareObjectType(type, x16, x17, FUNCTION_TEMPLATE_INFO_TYPE); - __ B(ne, &next_prototype); - - // Otherwise load the parent function template and iterate. - __ Ldr(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ B(&function_template_loop); - - // Load the next prototype. - __ Bind(&next_prototype); - __ Ldr(x16, FieldMemOperand(map, Map::kBitField3Offset)); - __ Tst(x16, Operand(Map::HasHiddenPrototype::kMask)); - __ B(eq, receiver_check_failed); - __ Ldr(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ Ldr(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ B(&prototype_loop_start); - - __ Bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- x0 : number of arguments excluding receiver - // -- x1 : callee - // -- lr : return address - // -- sp[0] : last argument - // -- ... - // -- sp[8 * (argc - 1)] : first argument - // -- sp[8 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); - __ Ldr(x3, FieldMemOperand(x3, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ Ldr(x2, MemOperand(jssp, x0, LSL, kPointerSizeLog2)); - CompatibleReceiverCheck(masm, x2, x3, x4, x5, x6, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ Ldr(x4, FieldMemOperand(x3, FunctionTemplateInfo::kCallCodeOffset)); - __ Ldr(x4, FieldMemOperand(x4, CallHandlerInfo::kFastHandlerOffset)); - __ Add(x4, x4, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ Jump(x4); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ Bind(&receiver_check_failed); - // Drop the arguments (including the receiver) - __ add(x0, x0, Operand(1)); - __ Drop(x0); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/builtins.h b/deps/v8/src/builtins/builtins.h index f2b0c4f0957674..7804fe859cd4a6 100644 --- a/deps/v8/src/builtins/builtins.h +++ b/deps/v8/src/builtins/builtins.h @@ -182,7 +182,6 @@ class Isolate; API(HandleApiCall) \ API(HandleApiCallAsFunction) \ API(HandleApiCallAsConstructor) \ - ASM(HandleFastApiCall) \ \ /* Adapters for Turbofan into runtime */ \ ASM(AllocateInNewSpace) \ diff --git a/deps/v8/src/builtins/ia32/builtins-ia32.cc b/deps/v8/src/builtins/ia32/builtins-ia32.cc index c074dd88eadbbf..247a841fd26bfb 100644 --- a/deps/v8/src/builtins/ia32/builtins-ia32.cc +++ b/deps/v8/src/builtins/ia32/builtins-ia32.cc @@ -3240,112 +3240,6 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { } } -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Register scratch0, Register scratch1, - Label* receiver_check_failed) { - // If there is no signature, return the holder. - __ CompareRoot(FieldOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset), - Heap::kUndefinedValueRootIndex); - Label receiver_check_passed; - __ j(equal, &receiver_check_passed, Label::kNear); - - // Walk the prototype chain. - __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(scratch0, scratch0, scratch1); - __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE); - Label next_prototype; - __ j(not_equal, &next_prototype, Label::kNear); - - // Get the constructor's signature. - __ mov(scratch0, - FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset)); - __ mov(scratch0, - FieldOperand(scratch0, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ cmp(scratch0, FieldOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - __ j(equal, &receiver_check_passed, Label::kNear); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(scratch0, &next_prototype, Label::kNear); - __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1); - __ j(not_equal, &next_prototype, Label::kNear); - - // Otherwise load the parent function template and iterate. - __ mov(scratch0, - FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset)); - __ jmp(&function_template_loop, Label::kNear); - - // Load the next prototype. - __ bind(&next_prototype); - __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset)); - __ test(FieldOperand(receiver, Map::kBitField3Offset), - Immediate(Map::HasHiddenPrototype::kMask)); - __ j(zero, receiver_check_failed); - - __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset)); - __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ jmp(&prototype_loop_start, Label::kNear); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- eax : number of arguments (not including the receiver) - // -- edi : callee - // -- esi : context - // -- esp[0] : return address - // -- esp[4] : last argument - // -- ... - // -- esp[eax * 4] : first argument - // -- esp[(eax + 1) * 4] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); - __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ mov(ecx, Operand(esp, eax, times_pointer_size, kPCOnStackSize)); - __ Push(eax); - CompatibleReceiverCheck(masm, ecx, ebx, edx, eax, &receiver_check_failed); - __ Pop(eax); - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ mov(edx, FieldOperand(ebx, FunctionTemplateInfo::kCallCodeOffset)); - __ mov(edx, FieldOperand(edx, CallHandlerInfo::kFastHandlerOffset)); - __ add(edx, Immediate(Code::kHeaderSize - kHeapObjectTag)); - __ jmp(edx); - - // Compatible receiver check failed: pop return address, arguments and - // receiver and throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - __ Pop(eax); - __ PopReturnAddressTo(ebx); - __ lea(eax, Operand(eax, times_pointer_size, 1 * kPointerSize)); - __ add(esp, eax); - __ PushReturnAddressFrom(ebx); - { - FrameScope scope(masm, StackFrame::INTERNAL); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); - } -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/mips/builtins-mips.cc b/deps/v8/src/builtins/mips/builtins-mips.cc index fe975e29e9e576..4c74f1601301ce 100644 --- a/deps/v8/src/builtins/mips/builtins-mips.cc +++ b/deps/v8/src/builtins/mips/builtins-mips.cc @@ -1723,104 +1723,6 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); } -// Clobbers {t2, t3, t4, t5}. -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Label* receiver_check_failed) { - Register signature = t2; - Register map = t3; - Register constructor = t4; - Register scratch = t5; - - // If there is no signature, return the holder. - __ lw(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - Label receiver_check_passed; - __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, - &receiver_check_passed); - - // Walk the prototype chain. - __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, scratch, scratch); - Label next_prototype; - __ Branch(&next_prototype, ne, scratch, Operand(JS_FUNCTION_TYPE)); - Register type = constructor; - __ lw(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ lw(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ Branch(&receiver_check_passed, eq, signature, Operand(type), - USE_DELAY_SLOT); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ GetObjectType(type, scratch, scratch); - __ Branch(&next_prototype, ne, scratch, Operand(FUNCTION_TEMPLATE_INFO_TYPE)); - - // Otherwise load the parent function template and iterate. - __ lw(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ Branch(&function_template_loop); - - // Load the next prototype and iterate. - __ bind(&next_prototype); - __ lw(scratch, FieldMemOperand(map, Map::kBitField3Offset)); - __ DecodeField(scratch); - __ Branch(receiver_check_failed, eq, scratch, Operand(zero_reg)); - __ lw(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ lw(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - - __ Branch(&prototype_loop_start); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- a0 : number of arguments excluding receiver - // -- a1 : callee - // -- ra : return address - // -- sp[0] : last argument - // -- ... - // -- sp[4 * (argc - 1)] : first argument - // -- sp[4 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ lw(t1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); - __ lw(t1, FieldMemOperand(t1, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ Lsa(t8, sp, a0, kPointerSizeLog2); - __ lw(t0, MemOperand(t8)); - CompatibleReceiverCheck(masm, t0, t1, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ lw(t2, FieldMemOperand(t1, FunctionTemplateInfo::kCallCodeOffset)); - __ lw(t2, FieldMemOperand(t2, CallHandlerInfo::kFastHandlerOffset)); - __ Addu(t2, t2, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ Jump(t2); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - // Drop the arguments (including the receiver); - __ Addu(t8, t8, Operand(kPointerSize)); - __ addu(sp, t8, zero_reg); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/mips64/builtins-mips64.cc b/deps/v8/src/builtins/mips64/builtins-mips64.cc index 8fcce9fa26c0cc..467198bba737f4 100644 --- a/deps/v8/src/builtins/mips64/builtins-mips64.cc +++ b/deps/v8/src/builtins/mips64/builtins-mips64.cc @@ -1714,105 +1714,6 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); } -// Clobbers {t2, t3, a4, a5}. -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Label* receiver_check_failed) { - Register signature = t2; - Register map = t3; - Register constructor = a4; - Register scratch = a5; - - // If there is no signature, return the holder. - __ ld(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - Label receiver_check_passed; - __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, - &receiver_check_passed); - - // Walk the prototype chain. - __ ld(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, scratch, scratch); - Label next_prototype; - __ Branch(&next_prototype, ne, scratch, Operand(JS_FUNCTION_TYPE)); - Register type = constructor; - __ ld(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ ld(type, FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ Branch(&receiver_check_passed, eq, signature, Operand(type), - USE_DELAY_SLOT); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ GetObjectType(type, scratch, scratch); - __ Branch(&next_prototype, ne, scratch, Operand(FUNCTION_TEMPLATE_INFO_TYPE)); - - // Otherwise load the parent function template and iterate. - __ ld(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ Branch(&function_template_loop); - - // Load the next prototype. - __ bind(&next_prototype); - __ lwu(scratch, FieldMemOperand(map, Map::kBitField3Offset)); - __ DecodeField(scratch); - __ Branch(receiver_check_failed, eq, scratch, Operand(zero_reg)); - - __ ld(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ ld(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ Branch(&prototype_loop_start); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- a0 : number of arguments excluding receiver - // -- a1 : callee - // -- ra : return address - // -- sp[0] : last argument - // -- ... - // -- sp[8 * (argc - 1)] : first argument - // -- sp[8 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ ld(t1, FieldMemOperand(a1, JSFunction::kSharedFunctionInfoOffset)); - __ ld(t1, FieldMemOperand(t1, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check - Label receiver_check_failed; - __ Dlsa(t8, sp, a0, kPointerSizeLog2); - __ ld(t0, MemOperand(t8)); - CompatibleReceiverCheck(masm, t0, t1, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ ld(t2, FieldMemOperand(t1, FunctionTemplateInfo::kCallCodeOffset)); - __ ld(t2, FieldMemOperand(t2, CallHandlerInfo::kFastHandlerOffset)); - __ Daddu(t2, t2, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ Jump(t2); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - // Drop the arguments (including the receiver); - __ Daddu(t8, t8, Operand(kPointerSize)); - __ daddu(sp, t8, zero_reg); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/ppc/builtins-ppc.cc b/deps/v8/src/builtins/ppc/builtins-ppc.cc index be07f748c196cb..3dc580b85eceb9 100644 --- a/deps/v8/src/builtins/ppc/builtins-ppc.cc +++ b/deps/v8/src/builtins/ppc/builtins-ppc.cc @@ -1734,107 +1734,6 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); } -// Clobbers registers {r7, r8, r9, r10}. -void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Label* receiver_check_failed) { - Register signature = r7; - Register map = r8; - Register constructor = r9; - Register scratch = r10; - - // If there is no signature, return the holder. - __ LoadP(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - Label receiver_check_passed; - __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, - &receiver_check_passed); - - // Walk the prototype chain. - __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, scratch, scratch); - __ cmpi(scratch, Operand(JS_FUNCTION_TYPE)); - Label next_prototype; - __ bne(&next_prototype); - Register type = constructor; - __ LoadP(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ LoadP(type, - FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ cmp(signature, type); - __ beq(&receiver_check_passed); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ CompareObjectType(type, scratch, scratch, FUNCTION_TEMPLATE_INFO_TYPE); - __ bne(&next_prototype); - - // Otherwise load the parent function template and iterate. - __ LoadP(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ b(&function_template_loop); - - // Load the next prototype. - __ bind(&next_prototype); - __ lwz(scratch, FieldMemOperand(map, Map::kBitField3Offset)); - __ DecodeField(scratch, SetRC); - __ beq(receiver_check_failed, cr0); - - __ LoadP(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ b(&prototype_loop_start); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- r3 : number of arguments excluding receiver - // -- r4 : callee - // -- lr : return address - // -- sp[0] : last argument - // -- ... - // -- sp[4 * (argc - 1)] : first argument - // -- sp[4 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ LoadP(r6, FieldMemOperand(r4, JSFunction::kSharedFunctionInfoOffset)); - __ LoadP(r6, FieldMemOperand(r6, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ ShiftLeftImm(r11, r3, Operand(kPointerSizeLog2)); - __ LoadPX(r5, MemOperand(sp, r11)); - CompatibleReceiverCheck(masm, r5, r6, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ LoadP(r7, FieldMemOperand(r6, FunctionTemplateInfo::kCallCodeOffset)); - __ LoadP(r7, FieldMemOperand(r7, CallHandlerInfo::kFastHandlerOffset)); - __ addi(ip, r7, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ JumpToJSEntry(ip); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - // Drop the arguments (including the receiver); - __ addi(r11, r11, Operand(kPointerSize)); - __ add(sp, sp, r11); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/s390/builtins-s390.cc b/deps/v8/src/builtins/s390/builtins-s390.cc index 429282d69e15b1..552cd7ada6cb4d 100644 --- a/deps/v8/src/builtins/s390/builtins-s390.cc +++ b/deps/v8/src/builtins/s390/builtins-s390.cc @@ -1743,107 +1743,6 @@ void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); } -// Clobbers registers {r6, r7, r8, r9}. -void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Label* receiver_check_failed) { - Register signature = r6; - Register map = r7; - Register constructor = r8; - Register scratch = r9; - - // If there is no signature, return the holder. - __ LoadP(signature, FieldMemOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - Label receiver_check_passed; - __ JumpIfRoot(signature, Heap::kUndefinedValueRootIndex, - &receiver_check_passed); - - // Walk the prototype chain. - __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, scratch, scratch); - __ CmpP(scratch, Operand(JS_FUNCTION_TYPE)); - Label next_prototype; - __ bne(&next_prototype); - Register type = constructor; - __ LoadP(type, - FieldMemOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ LoadP(type, - FieldMemOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ CmpP(signature, type); - __ beq(&receiver_check_passed); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype); - __ CompareObjectType(type, scratch, scratch, FUNCTION_TEMPLATE_INFO_TYPE); - __ bne(&next_prototype); - - // Otherwise load the parent function template and iterate. - __ LoadP(type, - FieldMemOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ b(&function_template_loop); - - // Load the next prototype. - __ bind(&next_prototype); - __ LoadlW(scratch, FieldMemOperand(map, Map::kBitField3Offset)); - __ DecodeField(scratch); - __ beq(receiver_check_failed); - - __ LoadP(receiver, FieldMemOperand(map, Map::kPrototypeOffset)); - __ LoadP(map, FieldMemOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ b(&prototype_loop_start); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- r2 : number of arguments excluding receiver - // -- r3 : callee - // -- lr : return address - // -- sp[0] : last argument - // -- ... - // -- sp[4 * (argc - 1)] : first argument - // -- sp[4 * argc] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ LoadP(r5, FieldMemOperand(r3, JSFunction::kSharedFunctionInfoOffset)); - __ LoadP(r5, FieldMemOperand(r5, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ ShiftLeftP(r1, r2, Operand(kPointerSizeLog2)); - __ LoadP(r4, MemOperand(sp, r1)); - CompatibleReceiverCheck(masm, r4, r5, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ LoadP(r6, FieldMemOperand(r5, FunctionTemplateInfo::kCallCodeOffset)); - __ LoadP(r6, FieldMemOperand(r6, CallHandlerInfo::kFastHandlerOffset)); - __ AddP(ip, r6, Operand(Code::kHeaderSize - kHeapObjectTag)); - __ JumpToJSEntry(ip); - - // Compatible receiver check failed: throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - // Drop the arguments (including the receiver); - __ AddP(r1, r1, Operand(kPointerSize)); - __ AddP(sp, sp, r1); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/x64/builtins-x64.cc b/deps/v8/src/builtins/x64/builtins-x64.cc index 703a7e7aa8e86e..6e4bf53fee17f4 100644 --- a/deps/v8/src/builtins/x64/builtins-x64.cc +++ b/deps/v8/src/builtins/x64/builtins-x64.cc @@ -3132,114 +3132,6 @@ void Builtins::Generate_ConstructWithSpread(MacroAssembler* masm) { __ Jump(masm->isolate()->builtins()->Construct(), RelocInfo::CODE_TARGET); } -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Register scratch0, Register scratch1, - Register scratch2, - Label* receiver_check_failed) { - Register signature = scratch0; - Register map = scratch1; - Register constructor = scratch2; - - // If there is no signature, return the holder. - __ movp(signature, FieldOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - __ CompareRoot(signature, Heap::kUndefinedValueRootIndex); - Label receiver_check_passed; - __ j(equal, &receiver_check_passed, Label::kNear); - - // Walk the prototype chain. - __ movp(map, FieldOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(constructor, map, kScratchRegister); - __ CmpInstanceType(kScratchRegister, JS_FUNCTION_TYPE); - Label next_prototype; - __ j(not_equal, &next_prototype, Label::kNear); - - // Get the constructor's signature. - Register type = constructor; - __ movp(type, - FieldOperand(constructor, JSFunction::kSharedFunctionInfoOffset)); - __ movp(type, FieldOperand(type, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ cmpp(signature, type); - __ j(equal, &receiver_check_passed, Label::kNear); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(type, &next_prototype, Label::kNear); - __ CmpObjectType(type, FUNCTION_TEMPLATE_INFO_TYPE, kScratchRegister); - __ j(not_equal, &next_prototype, Label::kNear); - - // Otherwise load the parent function template and iterate. - __ movp(type, - FieldOperand(type, FunctionTemplateInfo::kParentTemplateOffset)); - __ jmp(&function_template_loop, Label::kNear); - - // Load the next prototype. - __ bind(&next_prototype); - __ testq(FieldOperand(map, Map::kBitField3Offset), - Immediate(Map::HasHiddenPrototype::kMask)); - __ j(zero, receiver_check_failed); - __ movp(receiver, FieldOperand(map, Map::kPrototypeOffset)); - __ movp(map, FieldOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ jmp(&prototype_loop_start, Label::kNear); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- rax : number of arguments (not including the receiver) - // -- rdi : callee - // -- rsi : context - // -- rsp[0] : return address - // -- rsp[8] : last argument - // -- ... - // -- rsp[rax * 8] : first argument - // -- rsp[(rax + 1) * 8] : receiver - // ----------------------------------- - - StackArgumentsAccessor args(rsp, rax); - - // Load the FunctionTemplateInfo. - __ movp(rbx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); - __ movp(rbx, FieldOperand(rbx, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ movp(rcx, args.GetReceiverOperand()); - CompatibleReceiverCheck(masm, rcx, rbx, rdx, r8, r9, &receiver_check_failed); - - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ movp(rdx, FieldOperand(rbx, FunctionTemplateInfo::kCallCodeOffset)); - __ movp(rdx, FieldOperand(rdx, CallHandlerInfo::kFastHandlerOffset)); - __ addp(rdx, Immediate(Code::kHeaderSize - kHeapObjectTag)); - __ jmp(rdx); - - // Compatible receiver check failed: pop return address, arguments and - // receiver and throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - __ PopReturnAddressTo(rbx); - __ leap(rax, Operand(rax, times_pointer_size, 1 * kPointerSize)); - __ addp(rsp, rax); - __ PushReturnAddressFrom(rbx); - { - FrameScope scope(masm, StackFrame::INTERNAL); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); - } -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/builtins/x87/builtins-x87.cc b/deps/v8/src/builtins/x87/builtins-x87.cc index d13e868b028600..1bc87cfa062766 100644 --- a/deps/v8/src/builtins/x87/builtins-x87.cc +++ b/deps/v8/src/builtins/x87/builtins-x87.cc @@ -3175,112 +3175,6 @@ void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { } } -static void CompatibleReceiverCheck(MacroAssembler* masm, Register receiver, - Register function_template_info, - Register scratch0, Register scratch1, - Label* receiver_check_failed) { - // If there is no signature, return the holder. - __ CompareRoot(FieldOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset), - Heap::kUndefinedValueRootIndex); - Label receiver_check_passed; - __ j(equal, &receiver_check_passed, Label::kNear); - - // Walk the prototype chain. - __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); - Label prototype_loop_start; - __ bind(&prototype_loop_start); - - // Get the constructor, if any. - __ GetMapConstructor(scratch0, scratch0, scratch1); - __ CmpInstanceType(scratch1, JS_FUNCTION_TYPE); - Label next_prototype; - __ j(not_equal, &next_prototype, Label::kNear); - - // Get the constructor's signature. - __ mov(scratch0, - FieldOperand(scratch0, JSFunction::kSharedFunctionInfoOffset)); - __ mov(scratch0, - FieldOperand(scratch0, SharedFunctionInfo::kFunctionDataOffset)); - - // Loop through the chain of inheriting function templates. - Label function_template_loop; - __ bind(&function_template_loop); - - // If the signatures match, we have a compatible receiver. - __ cmp(scratch0, FieldOperand(function_template_info, - FunctionTemplateInfo::kSignatureOffset)); - __ j(equal, &receiver_check_passed, Label::kNear); - - // If the current type is not a FunctionTemplateInfo, load the next prototype - // in the chain. - __ JumpIfSmi(scratch0, &next_prototype, Label::kNear); - __ CmpObjectType(scratch0, FUNCTION_TEMPLATE_INFO_TYPE, scratch1); - __ j(not_equal, &next_prototype, Label::kNear); - - // Otherwise load the parent function template and iterate. - __ mov(scratch0, - FieldOperand(scratch0, FunctionTemplateInfo::kParentTemplateOffset)); - __ jmp(&function_template_loop, Label::kNear); - - // Load the next prototype. - __ bind(&next_prototype); - __ mov(receiver, FieldOperand(receiver, HeapObject::kMapOffset)); - __ test(FieldOperand(receiver, Map::kBitField3Offset), - Immediate(Map::HasHiddenPrototype::kMask)); - __ j(zero, receiver_check_failed); - - __ mov(receiver, FieldOperand(receiver, Map::kPrototypeOffset)); - __ mov(scratch0, FieldOperand(receiver, HeapObject::kMapOffset)); - // Iterate. - __ jmp(&prototype_loop_start, Label::kNear); - - __ bind(&receiver_check_passed); -} - -void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { - // ----------- S t a t e ------------- - // -- eax : number of arguments (not including the receiver) - // -- edi : callee - // -- esi : context - // -- esp[0] : return address - // -- esp[4] : last argument - // -- ... - // -- esp[eax * 4] : first argument - // -- esp[(eax + 1) * 4] : receiver - // ----------------------------------- - - // Load the FunctionTemplateInfo. - __ mov(ebx, FieldOperand(edi, JSFunction::kSharedFunctionInfoOffset)); - __ mov(ebx, FieldOperand(ebx, SharedFunctionInfo::kFunctionDataOffset)); - - // Do the compatible receiver check. - Label receiver_check_failed; - __ mov(ecx, Operand(esp, eax, times_pointer_size, kPCOnStackSize)); - __ Push(eax); - CompatibleReceiverCheck(masm, ecx, ebx, edx, eax, &receiver_check_failed); - __ Pop(eax); - // Get the callback offset from the FunctionTemplateInfo, and jump to the - // beginning of the code. - __ mov(edx, FieldOperand(ebx, FunctionTemplateInfo::kCallCodeOffset)); - __ mov(edx, FieldOperand(edx, CallHandlerInfo::kFastHandlerOffset)); - __ add(edx, Immediate(Code::kHeaderSize - kHeapObjectTag)); - __ jmp(edx); - - // Compatible receiver check failed: pop return address, arguments and - // receiver and throw an Illegal Invocation exception. - __ bind(&receiver_check_failed); - __ Pop(eax); - __ PopReturnAddressTo(ebx); - __ lea(eax, Operand(eax, times_pointer_size, 1 * kPointerSize)); - __ add(esp, eax); - __ PushReturnAddressFrom(ebx); - { - FrameScope scope(masm, StackFrame::INTERNAL); - __ TailCallRuntime(Runtime::kThrowIllegalInvocation); - } -} - static void Generate_OnStackReplacementHelper(MacroAssembler* masm, bool has_handler_frame) { // Lookup the function in the JavaScript frame. diff --git a/deps/v8/src/compilation-dependencies.cc b/deps/v8/src/compilation-dependencies.cc index dfd7cfe57e8b9b..cd14bcf338ff82 100644 --- a/deps/v8/src/compilation-dependencies.cc +++ b/deps/v8/src/compilation-dependencies.cc @@ -13,7 +13,7 @@ namespace v8 { namespace internal { -DependentCode* CompilationDependencies::Get(Handle object) { +DependentCode* CompilationDependencies::Get(Handle object) const { if (object->IsMap()) { return Handle::cast(object)->dependent_code(); } else if (object->IsPropertyCell()) { diff --git a/deps/v8/src/compilation-dependencies.h b/deps/v8/src/compilation-dependencies.h index 9a8229e029fbd8..516962aa7d7cdf 100644 --- a/deps/v8/src/compilation-dependencies.h +++ b/deps/v8/src/compilation-dependencies.h @@ -63,7 +63,7 @@ class CompilationDependencies { bool aborted_; ZoneList >* groups_[DependentCode::kGroupCount]; - DependentCode* Get(Handle object); + DependentCode* Get(Handle object) const; void Set(Handle object, Handle dep); }; } // namespace internal diff --git a/deps/v8/src/compiler/access-info.cc b/deps/v8/src/compiler/access-info.cc index 8fef2f079cc84c..ceeec5e3cb5a1c 100644 --- a/deps/v8/src/compiler/access-info.cc +++ b/deps/v8/src/compiler/access-info.cc @@ -372,9 +372,6 @@ bool AccessInfoFactory::ComputePropertyAccessInfo( if (!optimization.is_simple_api_call()) { return false; } - if (optimization.api_call_info()->fast_handler()->IsCode()) { - return false; - } if (V8_UNLIKELY(FLAG_runtime_stats)) return false; } if (access_mode == AccessMode::kLoad) { diff --git a/deps/v8/src/compiler/branch-elimination.cc b/deps/v8/src/compiler/branch-elimination.cc index 2d9a084e215f6f..96327e7856e87e 100644 --- a/deps/v8/src/compiler/branch-elimination.cc +++ b/deps/v8/src/compiler/branch-elimination.cc @@ -175,9 +175,8 @@ Reduction BranchElimination::ReduceStart(Node* node) { return UpdateConditions(node, ControlPathConditions::Empty(zone_)); } - const BranchElimination::ControlPathConditions* -BranchElimination::PathConditionsForControlNodes::Get(Node* node) { +BranchElimination::PathConditionsForControlNodes::Get(Node* node) const { if (static_cast(node->id()) < info_for_node_.size()) { return info_for_node_[node->id()]; } diff --git a/deps/v8/src/compiler/branch-elimination.h b/deps/v8/src/compiler/branch-elimination.h index 3c2cdb25a85013..c1431523e59af0 100644 --- a/deps/v8/src/compiler/branch-elimination.h +++ b/deps/v8/src/compiler/branch-elimination.h @@ -69,7 +69,7 @@ class V8_EXPORT_PRIVATE BranchElimination final public: PathConditionsForControlNodes(Zone* zone, size_t size_hint) : info_for_node_(size_hint, nullptr, zone) {} - const ControlPathConditions* Get(Node* node); + const ControlPathConditions* Get(Node* node) const; void Set(Node* node, const ControlPathConditions* conditions); private: diff --git a/deps/v8/src/deoptimizer.h b/deps/v8/src/deoptimizer.h index 5501ca6cf291f4..45a1846a9377e1 100644 --- a/deps/v8/src/deoptimizer.h +++ b/deps/v8/src/deoptimizer.h @@ -1023,7 +1023,7 @@ class MaterializedObjectStore { bool Remove(Address fp); private: - Isolate* isolate() { return isolate_; } + Isolate* isolate() const { return isolate_; } Handle GetStackEntries(); Handle EnsureStackEntries(int size); diff --git a/deps/v8/src/fast-accessor-assembler.cc b/deps/v8/src/fast-accessor-assembler.cc deleted file mode 100644 index 6e7b49ea0b2508..00000000000000 --- a/deps/v8/src/fast-accessor-assembler.cc +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "src/fast-accessor-assembler.h" - -#include "src/base/logging.h" -#include "src/code-stub-assembler.h" -#include "src/code-stubs.h" // For CallApiCallbackStub. -#include "src/handles-inl.h" -#include "src/objects-inl.h" -#include "src/objects.h" // For FAA::LoadInternalField impl. - -namespace v8 { -namespace internal { - -using compiler::Node; -using compiler::CodeAssemblerLabel; -using compiler::CodeAssemblerVariable; - -FastAccessorAssembler::FastAccessorAssembler(Isolate* isolate) - : zone_(isolate->allocator(), ZONE_NAME), - isolate_(isolate), - assembler_state_(new compiler::CodeAssemblerState( - isolate, zone(), 1, Code::ComputeFlags(Code::STUB), - "FastAccessorAssembler")), - assembler_(new CodeStubAssembler(assembler_state_.get())), - state_(kBuilding) {} - -FastAccessorAssembler::~FastAccessorAssembler() { Clear(); } - -FastAccessorAssembler::ValueId FastAccessorAssembler::IntegerConstant( - int const_value) { - CHECK_EQ(kBuilding, state_); - return FromRaw(assembler_->NumberConstant(const_value)); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::GetReceiver() { - CHECK_EQ(kBuilding, state_); - - // For JS functions, the receiver is parameter 0. - return FromRaw(assembler_->Parameter(0)); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::LoadInternalField( - ValueId value_id, int field_no) { - CHECK_EQ(kBuilding, state_); - - CodeAssemblerVariable result(assembler_.get(), - MachineRepresentation::kTagged); - LabelId is_not_jsobject = MakeLabel(); - CodeAssemblerLabel merge(assembler_.get(), &result); - - CheckIsJSObjectOrJump(value_id, is_not_jsobject); - - Node* internal_field = assembler_->LoadObjectField( - FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no); - - result.Bind(internal_field); - assembler_->Goto(&merge); - - // Return null, mimicking the C++ counterpart. - SetLabel(is_not_jsobject); - result.Bind(assembler_->NullConstant()); - assembler_->Goto(&merge); - - // Return. - assembler_->Bind(&merge); - return FromRaw(result.value()); -} - -FastAccessorAssembler::ValueId -FastAccessorAssembler::LoadInternalFieldUnchecked(ValueId value_id, - int field_no) { - CHECK_EQ(kBuilding, state_); - - // Defensive debug checks. - if (FLAG_debug_code) { - LabelId is_jsobject = MakeLabel(); - LabelId is_not_jsobject = MakeLabel(); - CheckIsJSObjectOrJump(value_id, is_not_jsobject); - assembler_->Goto(FromId(is_jsobject)); - - SetLabel(is_not_jsobject); - assembler_->DebugBreak(); - assembler_->Goto(FromId(is_jsobject)); - - SetLabel(is_jsobject); - } - - Node* result = assembler_->LoadObjectField( - FromId(value_id), JSObject::kHeaderSize + kPointerSize * field_no); - - return FromRaw(result); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::LoadValue( - ValueId value_id, int offset) { - CHECK_EQ(kBuilding, state_); - return FromRaw(assembler_->LoadBufferObject(FromId(value_id), offset, - MachineType::IntPtr())); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::LoadObject( - ValueId value_id, int offset) { - CHECK_EQ(kBuilding, state_); - return FromRaw(assembler_->LoadBufferObject( - assembler_->LoadBufferObject(FromId(value_id), offset), 0, - MachineType::AnyTagged())); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::ToSmi(ValueId value_id) { - CHECK_EQ(kBuilding, state_); - return FromRaw(assembler_->SmiTag(FromId(value_id))); -} - -void FastAccessorAssembler::ReturnValue(ValueId value_id) { - CHECK_EQ(kBuilding, state_); - assembler_->Return(FromId(value_id)); -} - -void FastAccessorAssembler::CheckFlagSetOrReturnNull(ValueId value_id, - int mask) { - CHECK_EQ(kBuilding, state_); - CodeAssemblerLabel pass(assembler_.get()); - CodeAssemblerLabel fail(assembler_.get()); - Node* value = FromId(value_id); - assembler_->Branch( - assembler_->IsSetWord(assembler_->BitcastTaggedToWord(value), mask), - &pass, &fail); - assembler_->Bind(&fail); - assembler_->Return(assembler_->NullConstant()); - assembler_->Bind(&pass); -} - -void FastAccessorAssembler::CheckNotZeroOrReturnNull(ValueId value_id) { - CHECK_EQ(kBuilding, state_); - CodeAssemblerLabel is_null(assembler_.get()); - CodeAssemblerLabel not_null(assembler_.get()); - assembler_->Branch( - assembler_->WordEqual(FromId(value_id), assembler_->SmiConstant(0)), - &is_null, ¬_null); - assembler_->Bind(&is_null); - assembler_->Return(assembler_->NullConstant()); - assembler_->Bind(¬_null); -} - -FastAccessorAssembler::LabelId FastAccessorAssembler::MakeLabel() { - CHECK_EQ(kBuilding, state_); - return FromRaw(new CodeAssemblerLabel(assembler_.get())); -} - -void FastAccessorAssembler::SetLabel(LabelId label_id) { - CHECK_EQ(kBuilding, state_); - assembler_->Bind(FromId(label_id)); -} - -void FastAccessorAssembler::Goto(LabelId label_id) { - CHECK_EQ(kBuilding, state_); - assembler_->Goto(FromId(label_id)); -} - -void FastAccessorAssembler::CheckNotZeroOrJump(ValueId value_id, - LabelId label_id) { - CHECK_EQ(kBuilding, state_); - CodeAssemblerLabel pass(assembler_.get()); - assembler_->Branch( - assembler_->WordEqual(FromId(value_id), assembler_->SmiConstant(0)), - FromId(label_id), &pass); - assembler_->Bind(&pass); -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::Call( - FunctionCallback callback_function, ValueId arg) { - CHECK_EQ(kBuilding, state_); - - // Wrap the FunctionCallback in an ExternalReference. - ApiFunction callback_api_function(FUNCTION_ADDR(callback_function)); - ExternalReference callback(&callback_api_function, - ExternalReference::DIRECT_API_CALL, isolate()); - - // Create & call API callback via stub. - const int kJSParameterCount = 1; - CallApiCallbackStub stub(isolate(), kJSParameterCount, true, true); - CallInterfaceDescriptor descriptor = stub.GetCallInterfaceDescriptor(); - DCHECK_EQ(4, descriptor.GetParameterCount()); - DCHECK_EQ(0, descriptor.GetStackParameterCount()); - Node* context = assembler_->GetJSContextParameter(); - Node* target = assembler_->HeapConstant(stub.GetCode()); - - Node* call = assembler_->CallStub( - descriptor, target, context, - assembler_->UndefinedConstant(), // callee (there's no JSFunction) - assembler_->UndefinedConstant(), // call_data (undefined) - assembler_->Parameter(0), // receiver (same as holder in this case) - assembler_->ExternalConstant(callback), // API callback function - FromId(arg)); // JS argument, on stack - return FromRaw(call); -} - -void FastAccessorAssembler::CheckIsJSObjectOrJump(ValueId value_id, - LabelId label_id) { - CHECK_EQ(kBuilding, state_); - - // Determine the 'value' object's instance type. - Node* instance_type = assembler_->LoadInstanceType(FromId(value_id)); - - CodeAssemblerLabel is_jsobject(assembler_.get()); - - // Check whether we have a proper JSObject. - assembler_->GotoIf( - assembler_->Word32Equal( - instance_type, assembler_->Int32Constant(Internals::kJSObjectType)), - &is_jsobject); - - // JSApiObject?. - assembler_->GotoIfNot( - assembler_->Word32Equal(instance_type, assembler_->Int32Constant( - Internals::kJSApiObjectType)), - FromId(label_id)); - - // Continue. - assembler_->Goto(&is_jsobject); - assembler_->Bind(&is_jsobject); -} - -MaybeHandle FastAccessorAssembler::Build() { - CHECK_EQ(kBuilding, state_); - Handle code = - compiler::CodeAssembler::GenerateCode(assembler_state_.get()); - state_ = !code.is_null() ? kBuilt : kError; - Clear(); - return code; -} - -FastAccessorAssembler::ValueId FastAccessorAssembler::FromRaw(Node* node) { - nodes_.push_back(node); - ValueId value_id = {nodes_.size() - 1}; - return value_id; -} - -FastAccessorAssembler::LabelId FastAccessorAssembler::FromRaw( - CodeAssemblerLabel* label) { - labels_.push_back(label); - LabelId label_id = {labels_.size() - 1}; - return label_id; -} - -Node* FastAccessorAssembler::FromId(ValueId value) const { - CHECK_LT(value.value_id, nodes_.size()); - CHECK_NOT_NULL(nodes_.at(value.value_id)); - return nodes_.at(value.value_id); -} - -CodeAssemblerLabel* FastAccessorAssembler::FromId(LabelId label) const { - CHECK_LT(label.label_id, labels_.size()); - CHECK_NOT_NULL(labels_.at(label.label_id)); - return labels_.at(label.label_id); -} - -void FastAccessorAssembler::Clear() { - for (auto label : labels_) { - delete label; - } - nodes_.clear(); - labels_.clear(); -} - -} // namespace internal -} // namespace v8 diff --git a/deps/v8/src/fast-accessor-assembler.h b/deps/v8/src/fast-accessor-assembler.h deleted file mode 100644 index f51d5a79e829eb..00000000000000 --- a/deps/v8/src/fast-accessor-assembler.h +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_FAST_ACCESSOR_ASSEMBLER_H_ -#define V8_FAST_ACCESSOR_ASSEMBLER_H_ - -#include -#include -#include - -#include "include/v8-experimental.h" -#include "src/base/macros.h" -#include "src/zone/zone.h" - -namespace v8 { -namespace internal { - -class Code; -class CodeStubAssembler; -class Isolate; -template -class MaybeHandle; - -namespace compiler { -class Node; -class CodeAssemblerLabel; -class CodeAssemblerState; -class CodeAssemblerVariable; -} - -// This interface "exports" an aggregated subset of RawMachineAssembler, for -// use by the API to implement Fast Dom Accessors. -// -// This interface is made for this single purpose only and does not attempt -// to implement a general purpose solution. If you need one, please look at -// RawMachineAssembler instead. -// -// The life cycle of a FastAccessorAssembler has two phases: -// - After creating the instance, you can call an arbitrary sequence of -// builder functions to build the desired function. -// - When done, you can Build() the accessor and query for the build results. -// -// You cannot call any result getters before Build() was called & successful; -// and you cannot call any builder functions after Build() was called. -class FastAccessorAssembler { - public: - typedef v8::experimental::FastAccessorBuilder::ValueId ValueId; - typedef v8::experimental::FastAccessorBuilder::LabelId LabelId; - typedef v8::FunctionCallback FunctionCallback; - - explicit FastAccessorAssembler(Isolate* isolate); - ~FastAccessorAssembler(); - - // Builder / assembler functions: - ValueId IntegerConstant(int int_constant); - ValueId GetReceiver(); - ValueId LoadInternalField(ValueId value_id, int field_no); - - // Loads internal field and assumes the object is indeed a valid API object - // with the proper internal fields present. - // The intended use is to call this on an object whose structure has already - // been checked previously, e.g. the accessor's receiver, which is map-checked - // before the fast accessor is called on it. Using this on an arbitrary object - // will result in unsafe memory accesses. - ValueId LoadInternalFieldUnchecked(ValueId value_id, int field_no); - - ValueId LoadValue(ValueId value_id, int offset); - ValueId LoadObject(ValueId value_id, int offset); - - // Converts a machine integer to a SMI. - ValueId ToSmi(ValueId value_id); - - // Builder / assembler functions for control flow. - void ReturnValue(ValueId value_id); - void CheckFlagSetOrReturnNull(ValueId value_id, int mask); - void CheckNotZeroOrReturnNull(ValueId value_id); - LabelId MakeLabel(); - void SetLabel(LabelId label_id); - void Goto(LabelId label_id); - void CheckNotZeroOrJump(ValueId value_id, LabelId label_id); - - // C++ callback. - ValueId Call(FunctionCallback callback, ValueId arg); - - // Assemble the code. - MaybeHandle Build(); - - private: - ValueId FromRaw(compiler::Node* node); - LabelId FromRaw(compiler::CodeAssemblerLabel* label); - compiler::Node* FromId(ValueId value) const; - compiler::CodeAssemblerLabel* FromId(LabelId value) const; - - void CheckIsJSObjectOrJump(ValueId value, LabelId label_id); - - void Clear(); - Zone* zone() { return &zone_; } - Isolate* isolate() const { return isolate_; } - - Zone zone_; - Isolate* isolate_; - std::unique_ptr assembler_state_; - std::unique_ptr assembler_; - - // To prevent exposing the RMA internals to the outside world, we'll map - // Node + Label pointers integers wrapped in ValueId and LabelId instances. - // These vectors maintain this mapping. - std::vector nodes_; - std::vector labels_; - - // Remember the current state for easy error checking. (We prefer to be - // strict as this class will be exposed at the API.) - enum { kBuilding, kBuilt, kError } state_; - - DISALLOW_COPY_AND_ASSIGN(FastAccessorAssembler); -}; - -} // namespace internal -} // namespace v8 - -#endif // V8_FAST_ACCESSOR_ASSEMBLER_H_ diff --git a/deps/v8/src/global-handles.cc b/deps/v8/src/global-handles.cc index ff7f132305cd73..95c5c82bc2d341 100644 --- a/deps/v8/src/global-handles.cc +++ b/deps/v8/src/global-handles.cc @@ -13,18 +13,6 @@ namespace v8 { namespace internal { - -ObjectGroup::~ObjectGroup() { - if (info != NULL) info->Dispose(); - delete[] objects; -} - - -ImplicitRefGroup::~ImplicitRefGroup() { - delete[] children; -} - - class GlobalHandles::Node { public: // State transition diagram: @@ -544,8 +532,7 @@ GlobalHandles::GlobalHandles(Isolate* isolate) first_used_block_(NULL), first_free_(NULL), post_gc_processing_count_(0), - number_of_phantom_handle_resets_(0), - object_group_connections_(kObjectGroupConnectionsCapacity) {} + number_of_phantom_handle_resets_(0) {} GlobalHandles::~GlobalHandles() { NodeBlock* block = first_block_; @@ -760,158 +747,6 @@ template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< template void GlobalHandles::IterateNewSpaceWeakUnmodifiedRoots< GlobalHandles::HANDLE_PHANTOM_NODES_VISIT_OTHERS>(ObjectVisitor* v); -DISABLE_CFI_PERF -bool GlobalHandles::IterateObjectGroups(ObjectVisitor* v, - WeakSlotCallbackWithHeap can_skip) { - ComputeObjectGroupsAndImplicitReferences(); - int last = 0; - bool any_group_was_visited = false; - for (int i = 0; i < object_groups_.length(); i++) { - ObjectGroup* entry = object_groups_.at(i); - DCHECK(entry != NULL); - - Object*** objects = entry->objects; - bool group_should_be_visited = false; - for (size_t j = 0; j < entry->length; j++) { - Object* object = *objects[j]; - if (object->IsHeapObject()) { - if (!can_skip(isolate_->heap(), &object)) { - group_should_be_visited = true; - break; - } - } - } - - if (!group_should_be_visited) { - object_groups_[last++] = entry; - continue; - } - - // An object in the group requires visiting, so iterate over all - // objects in the group. - for (size_t j = 0; j < entry->length; ++j) { - Object* object = *objects[j]; - if (object->IsHeapObject()) { - v->VisitPointer(&object); - any_group_was_visited = true; - } - } - - // Once the entire group has been iterated over, set the object - // group to NULL so it won't be processed again. - delete entry; - object_groups_.at(i) = NULL; - } - object_groups_.Rewind(last); - return any_group_was_visited; -} - -namespace { -// Traces the information about object groups and implicit ref groups given by -// the embedder to the V8 during each gc prologue. -class ObjectGroupsTracer { - public: - explicit ObjectGroupsTracer(Isolate* isolate); - void Print(); - - private: - void PrintObjectGroup(ObjectGroup* group); - void PrintImplicitRefGroup(ImplicitRefGroup* group); - void PrintObject(Object* object); - void PrintConstructor(JSObject* js_object); - void PrintInternalFields(JSObject* js_object); - Isolate* isolate_; - DISALLOW_COPY_AND_ASSIGN(ObjectGroupsTracer); -}; - -ObjectGroupsTracer::ObjectGroupsTracer(Isolate* isolate) : isolate_(isolate) {} - -void ObjectGroupsTracer::Print() { - GlobalHandles* global_handles = isolate_->global_handles(); - - PrintIsolate(isolate_, "### Tracing object groups:\n"); - - for (auto group : *(global_handles->object_groups())) { - PrintObjectGroup(group); - } - for (auto group : *(global_handles->implicit_ref_groups())) { - PrintImplicitRefGroup(group); - } - - PrintIsolate(isolate_, "### Tracing object groups finished.\n"); -} - -void ObjectGroupsTracer::PrintObject(Object* object) { - if (object->IsJSObject()) { - JSObject* js_object = JSObject::cast(object); - - PrintF("{ constructor_name: "); - PrintConstructor(js_object); - PrintF(", hidden_fields: [ "); - PrintInternalFields(js_object); - PrintF(" ] }\n"); - } else { - PrintF("object of unexpected type: %p\n", static_cast(object)); - } -} - -void ObjectGroupsTracer::PrintConstructor(JSObject* js_object) { - Object* maybe_constructor = js_object->map()->GetConstructor(); - if (maybe_constructor->IsJSFunction()) { - JSFunction* constructor = JSFunction::cast(maybe_constructor); - String* name = String::cast(constructor->shared()->name()); - if (name->length() == 0) name = constructor->shared()->inferred_name(); - - PrintF("%s", name->ToCString().get()); - } else if (maybe_constructor->IsNull(isolate_)) { - if (js_object->IsOddball()) { - PrintF(""); - } else { - PrintF(""); - } - } else { - UNREACHABLE(); - } -} - -void ObjectGroupsTracer::PrintInternalFields(JSObject* js_object) { - for (int i = 0; i < js_object->GetInternalFieldCount(); ++i) { - if (i != 0) { - PrintF(", "); - } - PrintF("%p", static_cast(js_object->GetInternalField(i))); - } -} - -void ObjectGroupsTracer::PrintObjectGroup(ObjectGroup* group) { - PrintIsolate(isolate_, "ObjectGroup (size: %" PRIuS ")\n", group->length); - Object*** objects = group->objects; - - for (size_t i = 0; i < group->length; ++i) { - PrintIsolate(isolate_, " - Member: "); - PrintObject(*objects[i]); - } -} - -void ObjectGroupsTracer::PrintImplicitRefGroup(ImplicitRefGroup* group) { - PrintIsolate(isolate_, "ImplicitRefGroup (children count: %" PRIuS ")\n", - group->length); - PrintIsolate(isolate_, " - Parent: "); - PrintObject(*(group->parent)); - - Object*** children = group->children; - for (size_t i = 0; i < group->length; ++i) { - PrintIsolate(isolate_, " - Child: "); - PrintObject(*children[i]); - } -} - -} // namespace - -void GlobalHandles::PrintObjectGroups() { - ObjectGroupsTracer(isolate_).Print(); -} - void GlobalHandles::InvokeSecondPassPhantomCallbacks( List* callbacks, Isolate* isolate) { while (callbacks->length() != 0) { @@ -1233,184 +1068,10 @@ void GlobalHandles::Print() { #endif - - -void GlobalHandles::AddObjectGroup(Object*** handles, - size_t length, - v8::RetainedObjectInfo* info) { -#ifdef DEBUG - for (size_t i = 0; i < length; ++i) { - DCHECK(!Node::FromLocation(handles[i])->is_independent()); - } -#endif - if (length == 0) { - if (info != NULL) info->Dispose(); - return; - } - ObjectGroup* group = new ObjectGroup(length); - for (size_t i = 0; i < length; ++i) - group->objects[i] = handles[i]; - group->info = info; - object_groups_.Add(group); -} - - -void GlobalHandles::SetObjectGroupId(Object** handle, - UniqueId id) { - object_group_connections_.Add(ObjectGroupConnection(id, handle)); -} - - -void GlobalHandles::SetRetainedObjectInfo(UniqueId id, - RetainedObjectInfo* info) { - retainer_infos_.Add(ObjectGroupRetainerInfo(id, info)); -} - - -void GlobalHandles::SetReferenceFromGroup(UniqueId id, Object** child) { - DCHECK(!Node::FromLocation(child)->is_independent()); - implicit_ref_connections_.Add(ObjectGroupConnection(id, child)); -} - - -void GlobalHandles::SetReference(HeapObject** parent, Object** child) { - DCHECK(!Node::FromLocation(child)->is_independent()); - ImplicitRefGroup* group = new ImplicitRefGroup(parent, 1); - group->children[0] = child; - implicit_ref_groups_.Add(group); -} - - -void GlobalHandles::RemoveObjectGroups() { - for (int i = 0; i < object_groups_.length(); i++) - delete object_groups_.at(i); - object_groups_.Clear(); - for (int i = 0; i < retainer_infos_.length(); ++i) - retainer_infos_[i].info->Dispose(); - retainer_infos_.Clear(); - object_group_connections_.Clear(); - object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); -} - - -void GlobalHandles::RemoveImplicitRefGroups() { - for (int i = 0; i < implicit_ref_groups_.length(); i++) { - delete implicit_ref_groups_.at(i); - } - implicit_ref_groups_.Clear(); - implicit_ref_connections_.Clear(); -} - - void GlobalHandles::TearDown() { // TODO(1428): invoke weak callbacks. } - -void GlobalHandles::ComputeObjectGroupsAndImplicitReferences() { - if (object_group_connections_.length() == 0) { - for (int i = 0; i < retainer_infos_.length(); ++i) - retainer_infos_[i].info->Dispose(); - retainer_infos_.Clear(); - implicit_ref_connections_.Clear(); - return; - } - - object_group_connections_.Sort(); - retainer_infos_.Sort(); - implicit_ref_connections_.Sort(); - - int info_index = 0; // For iterating retainer_infos_. - UniqueId current_group_id(0); - int current_group_start = 0; - - int current_implicit_refs_start = 0; - int current_implicit_refs_end = 0; - for (int i = 0; i <= object_group_connections_.length(); ++i) { - if (i == 0) - current_group_id = object_group_connections_[i].id; - if (i == object_group_connections_.length() || - current_group_id != object_group_connections_[i].id) { - // Group detected: objects in indices [current_group_start, i[. - - // Find out which implicit references are related to this group. (We want - // to ignore object groups which only have 1 object, but that object is - // needed as a representative object for the implicit refrerence group.) - while (current_implicit_refs_start < implicit_ref_connections_.length() && - implicit_ref_connections_[current_implicit_refs_start].id < - current_group_id) - ++current_implicit_refs_start; - current_implicit_refs_end = current_implicit_refs_start; - while (current_implicit_refs_end < implicit_ref_connections_.length() && - implicit_ref_connections_[current_implicit_refs_end].id == - current_group_id) - ++current_implicit_refs_end; - - if (current_implicit_refs_end > current_implicit_refs_start) { - // Find a representative object for the implicit references. - HeapObject** representative = NULL; - for (int j = current_group_start; j < i; ++j) { - Object** object = object_group_connections_[j].object; - if ((*object)->IsHeapObject()) { - representative = reinterpret_cast(object); - break; - } - } - if (representative) { - ImplicitRefGroup* group = new ImplicitRefGroup( - representative, - current_implicit_refs_end - current_implicit_refs_start); - for (int j = current_implicit_refs_start; - j < current_implicit_refs_end; - ++j) { - group->children[j - current_implicit_refs_start] = - implicit_ref_connections_[j].object; - } - implicit_ref_groups_.Add(group); - } - current_implicit_refs_start = current_implicit_refs_end; - } - - // Find a RetainedObjectInfo for the group. - RetainedObjectInfo* info = NULL; - while (info_index < retainer_infos_.length() && - retainer_infos_[info_index].id < current_group_id) { - retainer_infos_[info_index].info->Dispose(); - ++info_index; - } - if (info_index < retainer_infos_.length() && - retainer_infos_[info_index].id == current_group_id) { - // This object group has an associated ObjectGroupRetainerInfo. - info = retainer_infos_[info_index].info; - ++info_index; - } - - // Ignore groups which only contain one object. - if (i > current_group_start + 1) { - ObjectGroup* group = new ObjectGroup(i - current_group_start); - for (int j = current_group_start; j < i; ++j) { - group->objects[j - current_group_start] = - object_group_connections_[j].object; - } - group->info = info; - object_groups_.Add(group); - } else if (info) { - info->Dispose(); - } - - if (i < object_group_connections_.length()) { - current_group_id = object_group_connections_[i].id; - current_group_start = i; - } - } - } - object_group_connections_.Clear(); - object_group_connections_.Initialize(kObjectGroupConnectionsCapacity); - retainer_infos_.Clear(); - implicit_ref_connections_.Clear(); -} - - EternalHandles::EternalHandles() : size_(0) { for (unsigned i = 0; i < arraysize(singleton_handles_); i++) { singleton_handles_[i] = kInvalidIndex; diff --git a/deps/v8/src/global-handles.h b/deps/v8/src/global-handles.h index 9c4ffb4f1a4351..d80f4a274c8884 100644 --- a/deps/v8/src/global-handles.h +++ b/deps/v8/src/global-handles.h @@ -24,78 +24,6 @@ class ObjectVisitor; // At GC the destroyed global handles are removed from the free list // and deallocated. -// Data structures for tracking object groups and implicit references. - -// An object group is treated like a single JS object: if one of object in -// the group is alive, all objects in the same group are considered alive. -// An object group is used to simulate object relationship in a DOM tree. - -// An implicit references group consists of two parts: a parent object and a -// list of children objects. If the parent is alive, all the children are alive -// too. - -struct ObjectGroup { - explicit ObjectGroup(size_t length) - : info(NULL), length(length) { - DCHECK(length > 0); - objects = new Object**[length]; - } - ~ObjectGroup(); - - v8::RetainedObjectInfo* info; - Object*** objects; - size_t length; -}; - - -struct ImplicitRefGroup { - ImplicitRefGroup(HeapObject** parent, size_t length) - : parent(parent), length(length) { - DCHECK(length > 0); - children = new Object**[length]; - } - ~ImplicitRefGroup(); - - HeapObject** parent; - Object*** children; - size_t length; -}; - - -// For internal bookkeeping. -struct ObjectGroupConnection { - ObjectGroupConnection(UniqueId id, Object** object) - : id(id), object(object) {} - - bool operator==(const ObjectGroupConnection& other) const { - return id == other.id; - } - - bool operator<(const ObjectGroupConnection& other) const { - return id < other.id; - } - - UniqueId id; - Object** object; -}; - - -struct ObjectGroupRetainerInfo { - ObjectGroupRetainerInfo(UniqueId id, RetainedObjectInfo* info) - : id(id), info(info) {} - - bool operator==(const ObjectGroupRetainerInfo& other) const { - return id == other.id; - } - - bool operator<(const ObjectGroupRetainerInfo& other) const { - return id < other.id; - } - - UniqueId id; - RetainedObjectInfo* info; -}; - enum WeaknessType { // Embedder gets a handle to the dying object. FINALIZER_WEAK, @@ -170,7 +98,7 @@ class GlobalHandles { // Clear the weakness of a global handle. static void* ClearWeakness(Object** location); - // Mark the reference to this object independent of any object group. + // Mark the reference to this object independent. static void MarkIndependent(Object** location); static bool IsIndependent(Object** location); @@ -240,55 +168,6 @@ class GlobalHandles { // unmodified void IdentifyWeakUnmodifiedObjects(WeakSlotCallback is_unmodified); - // Iterate over objects in object groups that have at least one object - // which requires visiting. The callback has to return true if objects - // can be skipped and false otherwise. - bool IterateObjectGroups(ObjectVisitor* v, WeakSlotCallbackWithHeap can_skip); - - // Print all objects in object groups - void PrintObjectGroups(); - - // Add an object group. - // Should be only used in GC callback function before a collection. - // All groups are destroyed after a garbage collection. - void AddObjectGroup(Object*** handles, - size_t length, - v8::RetainedObjectInfo* info); - - // Associates handle with the object group represented by id. - // Should be only used in GC callback function before a collection. - // All groups are destroyed after a garbage collection. - void SetObjectGroupId(Object** handle, UniqueId id); - - // Set RetainedObjectInfo for an object group. Should not be called more than - // once for a group. Should not be called for a group which contains no - // handles. - void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); - - // Adds an implicit reference from a group to an object. Should be only used - // in GC callback function before a collection. All implicit references are - // destroyed after a mark-compact collection. - void SetReferenceFromGroup(UniqueId id, Object** child); - - // Adds an implicit reference from a parent object to a child object. Should - // be only used in GC callback function before a collection. All implicit - // references are destroyed after a mark-compact collection. - void SetReference(HeapObject** parent, Object** child); - - List* object_groups() { - ComputeObjectGroupsAndImplicitReferences(); - return &object_groups_; - } - - List* implicit_ref_groups() { - ComputeObjectGroupsAndImplicitReferences(); - return &implicit_ref_groups_; - } - - // Remove bags, this should only happen after GC. - void RemoveObjectGroups(); - void RemoveImplicitRefGroups(); - // Tear down the global handle structure. void TearDown(); @@ -302,15 +181,6 @@ class GlobalHandles { private: explicit GlobalHandles(Isolate* isolate); - // Migrates data from the internal representation (object_group_connections_, - // retainer_infos_ and implicit_ref_connections_) to the public and more - // efficient representation (object_groups_ and implicit_ref_groups_). - void ComputeObjectGroupsAndImplicitReferences(); - - // v8::internal::List is inefficient even for small number of elements, if we - // don't assign any initial capacity. - static const int kObjectGroupConnectionsCapacity = 20; - class PendingPhantomCallback; // Helpers for PostGarbageCollectionProcessing. @@ -349,17 +219,6 @@ class GlobalHandles { size_t number_of_phantom_handle_resets_; - // Object groups and implicit references, public and more efficient - // representation. - List object_groups_; - List implicit_ref_groups_; - - // Object groups and implicit references, temporary representation while - // constructing the groups. - List object_group_connections_; - List retainer_infos_; - List implicit_ref_connections_; - List pending_phantom_callbacks_; friend class Isolate; diff --git a/deps/v8/src/heap/gc-tracer.cc b/deps/v8/src/heap/gc-tracer.cc index 2c1024f09ae01a..2a4b481805f802 100644 --- a/deps/v8/src/heap/gc-tracer.cc +++ b/deps/v8/src/heap/gc-tracer.cc @@ -537,7 +537,6 @@ void GCTracer::PrintNVP() const { "clear=%1.f " "clear.code_flush=%.1f " "clear.dependent_code=%.1f " - "clear.global_handles=%.1f " "clear.maps=%.1f " "clear.slots_buffer=%.1f " "clear.store_buffer=%.1f " @@ -563,7 +562,6 @@ void GCTracer::PrintNVP() const { "finish=%.1f " "mark=%.1f " "mark.finish_incremental=%.1f " - "mark.object_grouping=%.1f " "mark.prepare_code_flush=%.1f " "mark.roots=%.1f " "mark.weak_closure=%.1f " @@ -584,7 +582,6 @@ void GCTracer::PrintNVP() const { "incremental.finalize.body=%.1f " "incremental.finalize.external.prologue=%.1f " "incremental.finalize.external.epilogue=%.1f " - "incremental.finalize.object_grouping=%.1f " "incremental.sweeping=%.1f " "incremental.wrapper_prologue=%.1f " "incremental.wrapper_tracing=%.1f " @@ -623,7 +620,6 @@ void GCTracer::PrintNVP() const { current_.reduce_memory, current_.scopes[Scope::MC_CLEAR], current_.scopes[Scope::MC_CLEAR_CODE_FLUSH], current_.scopes[Scope::MC_CLEAR_DEPENDENT_CODE], - current_.scopes[Scope::MC_CLEAR_GLOBAL_HANDLES], current_.scopes[Scope::MC_CLEAR_MAPS], current_.scopes[Scope::MC_CLEAR_SLOTS_BUFFER], current_.scopes[Scope::MC_CLEAR_STORE_BUFFER], @@ -648,7 +644,6 @@ void GCTracer::PrintNVP() const { current_.scopes[Scope::EXTERNAL_WEAK_GLOBAL_HANDLES], current_.scopes[Scope::MC_FINISH], current_.scopes[Scope::MC_MARK], current_.scopes[Scope::MC_MARK_FINISH_INCREMENTAL], - current_.scopes[Scope::MC_MARK_OBJECT_GROUPING], current_.scopes[Scope::MC_MARK_PREPARE_CODE_FLUSH], current_.scopes[Scope::MC_MARK_ROOTS], current_.scopes[Scope::MC_MARK_WEAK_CLOSURE], @@ -668,7 +663,6 @@ void GCTracer::PrintNVP() const { current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_BODY], current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_PROLOGUE], current_.scopes[Scope::MC_INCREMENTAL_EXTERNAL_EPILOGUE], - current_.scopes[Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING], current_.scopes[Scope::MC_INCREMENTAL_SWEEPING], current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE], current_.scopes[Scope::MC_INCREMENTAL_WRAPPER_TRACING], diff --git a/deps/v8/src/heap/gc-tracer.h b/deps/v8/src/heap/gc-tracer.h index b2062861680581..55bd3e8d83ec86 100644 --- a/deps/v8/src/heap/gc-tracer.h +++ b/deps/v8/src/heap/gc-tracer.h @@ -31,7 +31,6 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; F(MC_INCREMENTAL_WRAPPER_TRACING) \ F(MC_INCREMENTAL_FINALIZE) \ F(MC_INCREMENTAL_FINALIZE_BODY) \ - F(MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING) \ F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \ F(MC_INCREMENTAL_EXTERNAL_PROLOGUE) @@ -43,7 +42,6 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; F(MC_CLEAR) \ F(MC_CLEAR_CODE_FLUSH) \ F(MC_CLEAR_DEPENDENT_CODE) \ - F(MC_CLEAR_GLOBAL_HANDLES) \ F(MC_CLEAR_MAPS) \ F(MC_CLEAR_SLOTS_BUFFER) \ F(MC_CLEAR_STORE_BUFFER) \ @@ -76,7 +74,6 @@ enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; F(MC_MARK_WRAPPER_EPILOGUE) \ F(MC_MARK_WRAPPER_PROLOGUE) \ F(MC_MARK_WRAPPER_TRACING) \ - F(MC_MARK_OBJECT_GROUPING) \ F(MC_PROLOGUE) \ F(MC_SWEEP) \ F(MC_SWEEP_CODE) \ diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index 1524a7821e02bd..d1fb1388405baa 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -1432,10 +1432,6 @@ void Heap::CallGCPrologueCallbacks(GCType gc_type, GCCallbackFlags flags) { } } } - if (FLAG_trace_object_groups && (gc_type == kGCTypeIncrementalMarking || - gc_type == kGCTypeMarkSweepCompact)) { - isolate_->global_handles()->PrintObjectGroups(); - } } diff --git a/deps/v8/src/heap/incremental-marking.cc b/deps/v8/src/heap/incremental-marking.cc index 9e8fdc726e8ff4..64d8c056c8eba2 100644 --- a/deps/v8/src/heap/incremental-marking.cc +++ b/deps/v8/src/heap/incremental-marking.cc @@ -591,24 +591,6 @@ void IncrementalMarking::MarkRoots() { heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); } - -void IncrementalMarking::MarkObjectGroups() { - TRACE_GC(heap_->tracer(), - GCTracer::Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING); - - DCHECK(!heap_->local_embedder_heap_tracer()->InUse()); - DCHECK(!finalize_marking_completed_); - DCHECK(IsMarking()); - - IncrementalMarkingRootMarkingVisitor visitor(this); - heap_->mark_compact_collector()->MarkImplicitRefGroups(&MarkGrey); - heap_->isolate()->global_handles()->IterateObjectGroups( - &visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap); - heap_->isolate()->global_handles()->RemoveImplicitRefGroups(); - heap_->isolate()->global_handles()->RemoveObjectGroups(); -} - - void IncrementalMarking::ProcessWeakCells() { DCHECK(!finalize_marking_completed_); DCHECK(IsMarking()); @@ -721,14 +703,11 @@ void IncrementalMarking::FinalizeIncrementally() { // After finishing incremental marking, we try to discover all unmarked // objects to reduce the marking load in the final pause. // 1) We scan and mark the roots again to find all changes to the root set. - // 2) We mark the object groups. - // 3) Age and retain maps embedded in optimized code. - // 4) Remove weak cell with live values from the list of weak cells, they + // 2) Age and retain maps embedded in optimized code. + // 3) Remove weak cell with live values from the list of weak cells, they // do not need processing during GC. MarkRoots(); - if (!heap_->local_embedder_heap_tracer()->InUse()) { - MarkObjectGroups(); - } + if (incremental_marking_finalization_rounds_ == 0) { // Map retaining is needed for perfromance, not correctness, // so we can do it only once at the beginning of the finalization. diff --git a/deps/v8/src/heap/incremental-marking.h b/deps/v8/src/heap/incremental-marking.h index 37f1e5cec114df..21a4b592ba1e06 100644 --- a/deps/v8/src/heap/incremental-marking.h +++ b/deps/v8/src/heap/incremental-marking.h @@ -244,7 +244,6 @@ class V8_EXPORT_PRIVATE IncrementalMarking { void FinishBlackAllocation(); void MarkRoots(); - void MarkObjectGroups(); void ProcessWeakCells(); // Retain dying maps for garbage collections to // increase chances of reusing of map transition tree in future. diff --git a/deps/v8/src/heap/mark-compact.cc b/deps/v8/src/heap/mark-compact.cc index 338d954ab020e3..9bee2cd2866211 100644 --- a/deps/v8/src/heap/mark-compact.cc +++ b/deps/v8/src/heap/mark-compact.cc @@ -1948,14 +1948,6 @@ bool MarkCompactCollector::IsUnmarkedHeapObject(Object** p) { return ObjectMarking::IsWhite(HeapObject::cast(o)); } - -bool MarkCompactCollector::IsUnmarkedHeapObjectWithHeap(Heap* heap, - Object** p) { - Object* o = *p; - DCHECK(o->IsHeapObject()); - return ObjectMarking::IsWhite(HeapObject::cast(o)); -} - void MarkCompactCollector::MarkStringTable( RootMarkingVisitor* visitor) { StringTable* string_table = heap()->string_table(); @@ -1985,38 +1977,6 @@ void MarkCompactCollector::MarkRoots( } } - -void MarkCompactCollector::MarkImplicitRefGroups( - MarkObjectFunction mark_object) { - List* ref_groups = - isolate()->global_handles()->implicit_ref_groups(); - - int last = 0; - for (int i = 0; i < ref_groups->length(); i++) { - ImplicitRefGroup* entry = ref_groups->at(i); - DCHECK(entry != NULL); - - if (ObjectMarking::IsWhite(*entry->parent)) { - (*ref_groups)[last++] = entry; - continue; - } - - Object*** children = entry->children; - // A parent object is marked, so mark all child heap objects. - for (size_t j = 0; j < entry->length; ++j) { - if ((*children[j])->IsHeapObject()) { - mark_object(heap(), HeapObject::cast(*children[j])); - } - } - - // Once the entire group has been marked, dispose it because it's - // not needed anymore. - delete entry; - } - ref_groups->Rewind(last); -} - - // Mark all objects reachable from the objects on the marking stack. // Before: the marking stack contains zero or more heap object pointers. // After: the marking stack is empty, and all objects reachable from the @@ -2104,11 +2064,6 @@ void MarkCompactCollector::ProcessEphemeralMarking( 0, EmbedderHeapTracer::AdvanceTracingActions( EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); - } else { - TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_OBJECT_GROUPING); - isolate()->global_handles()->IterateObjectGroups( - visitor, &IsUnmarkedHeapObjectWithHeap); - MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); } } else { // TODO(mlippautz): We currently do not trace through blink when @@ -2494,14 +2449,6 @@ void MarkCompactCollector::ClearNonLiveReferences() { heap()->ProcessAllWeakReferences(&mark_compact_object_retainer); } - { - TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_GLOBAL_HANDLES); - - // Remove object groups after marking phase. - heap()->isolate()->global_handles()->RemoveObjectGroups(); - heap()->isolate()->global_handles()->RemoveImplicitRefGroups(); - } - // Flush code from collected candidates. if (is_code_flushing_enabled()) { TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_CLEAR_CODE_FLUSH); diff --git a/deps/v8/src/heap/mark-compact.h b/deps/v8/src/heap/mark-compact.h index 86d0b9616b5048..da2ba4ee38dcfa 100644 --- a/deps/v8/src/heap/mark-compact.h +++ b/deps/v8/src/heap/mark-compact.h @@ -516,8 +516,6 @@ class MarkCompactCollector { static const uint32_t kSingleFreeEncoding = 0; static const uint32_t kMultiFreeEncoding = 1; - static bool IsUnmarkedHeapObjectWithHeap(Heap* heap, Object** p); - inline Heap* heap() const { return heap_; } inline Isolate* isolate() const; @@ -569,10 +567,6 @@ class MarkCompactCollector { bool evacuation() const { return evacuation_; } - // Mark objects in implicit references groups if their parent object - // is marked. - void MarkImplicitRefGroups(MarkObjectFunction mark_object); - MarkingDeque* marking_deque() { return &marking_deque_; } Sweeper& sweeper() { return sweeper_; } diff --git a/deps/v8/src/ic/arm/handler-compiler-arm.cc b/deps/v8/src/ic/arm/handler-compiler-arm.cc index ebef63ca660564..eddf005e96165e 100644 --- a/deps/v8/src/ic/arm/handler-compiler-arm.cc +++ b/deps/v8/src/ic/arm/handler-compiler-arm.cc @@ -288,13 +288,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ ldr(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } - // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/arm64/handler-compiler-arm64.cc b/deps/v8/src/ic/arm64/handler-compiler-arm64.cc index b7dc58974f392c..19d818cb2d999d 100644 --- a/deps/v8/src/ic/arm64/handler-compiler-arm64.cc +++ b/deps/v8/src/ic/arm64/handler-compiler-arm64.cc @@ -190,13 +190,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ Ldr(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } - // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/ia32/handler-compiler-ia32.cc b/deps/v8/src/ic/ia32/handler-compiler-ia32.cc index f0f8fadddea939..508490cd34b041 100644 --- a/deps/v8/src/ic/ia32/handler-compiler-ia32.cc +++ b/deps/v8/src/ic/ia32/handler-compiler-ia32.cc @@ -201,12 +201,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ mov(data, FieldOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the code. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); __ mov(api_function_address, Immediate(function_address)); diff --git a/deps/v8/src/ic/mips/handler-compiler-mips.cc b/deps/v8/src/ic/mips/handler-compiler-mips.cc index c14652cf4726c6..88d4817eb8b5a6 100644 --- a/deps/v8/src/ic/mips/handler-compiler-mips.cc +++ b/deps/v8/src/ic/mips/handler-compiler-mips.cc @@ -276,12 +276,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ lw(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/mips64/handler-compiler-mips64.cc b/deps/v8/src/ic/mips64/handler-compiler-mips64.cc index 1a38d329e7cc2a..feb8f2a27d9546 100644 --- a/deps/v8/src/ic/mips64/handler-compiler-mips64.cc +++ b/deps/v8/src/ic/mips64/handler-compiler-mips64.cc @@ -276,12 +276,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ ld(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/ppc/handler-compiler-ppc.cc b/deps/v8/src/ic/ppc/handler-compiler-ppc.cc index 3da558d10e6a57..fc447d03346051 100644 --- a/deps/v8/src/ic/ppc/handler-compiler-ppc.cc +++ b/deps/v8/src/ic/ppc/handler-compiler-ppc.cc @@ -282,13 +282,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ LoadP(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } - // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/s390/handler-compiler-s390.cc b/deps/v8/src/ic/s390/handler-compiler-s390.cc index 9f087977a1ec22..02f53339caa2db 100644 --- a/deps/v8/src/ic/s390/handler-compiler-s390.cc +++ b/deps/v8/src/ic/s390/handler-compiler-s390.cc @@ -272,13 +272,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ LoadP(data, FieldMemOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } - // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); ApiFunction fun(function_address); diff --git a/deps/v8/src/ic/x64/handler-compiler-x64.cc b/deps/v8/src/ic/x64/handler-compiler-x64.cc index 425ed4762e0d71..88bacad47bb637 100644 --- a/deps/v8/src/ic/x64/handler-compiler-x64.cc +++ b/deps/v8/src/ic/x64/handler-compiler-x64.cc @@ -176,13 +176,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ movp(data, FieldOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the fast handler if present. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } - // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); __ Move(api_function_address, function_address, diff --git a/deps/v8/src/ic/x87/handler-compiler-x87.cc b/deps/v8/src/ic/x87/handler-compiler-x87.cc index 5a61eee163e20b..6e5fe9f670b053 100644 --- a/deps/v8/src/ic/x87/handler-compiler-x87.cc +++ b/deps/v8/src/ic/x87/handler-compiler-x87.cc @@ -201,12 +201,6 @@ void PropertyHandlerCompiler::GenerateApiAccessorCall( __ mov(data, FieldOperand(data, CallHandlerInfo::kDataOffset)); } - if (api_call_info->fast_handler()->IsCode()) { - // Just tail call into the code. - __ Jump(handle(Code::cast(api_call_info->fast_handler())), - RelocInfo::CODE_TARGET); - return; - } // Put api_function_address in place. Address function_address = v8::ToCData
(api_call_info->callback()); __ mov(api_function_address, Immediate(function_address)); diff --git a/deps/v8/src/libplatform/default-platform.cc b/deps/v8/src/libplatform/default-platform.cc index 0e2144b64844d9..14e12d1f90e974 100644 --- a/deps/v8/src/libplatform/default-platform.cc +++ b/deps/v8/src/libplatform/default-platform.cc @@ -17,8 +17,8 @@ namespace v8 { namespace platform { - -v8::Platform* CreateDefaultPlatform(int thread_pool_size) { +v8::Platform* CreateDefaultPlatform(int thread_pool_size, + IdleTaskSupport idle_task_support) { DefaultPlatform* platform = new DefaultPlatform(); platform->SetThreadPoolSize(thread_pool_size); platform->EnsureInitialized(); diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index 3aa26c5601690e..6ac77270111b05 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -2523,8 +2523,7 @@ T* WeakFixedArray::Iterator::Next() { return NULL; } - -int ArrayList::Length() { +int ArrayList::Length() const { if (FixedArray::cast(this)->length() == 0) return 0; return Smi::cast(FixedArray::cast(this)->get(kLengthIndex))->value(); } @@ -2534,8 +2533,7 @@ void ArrayList::SetLength(int length) { return FixedArray::cast(this)->set(kLengthIndex, Smi::FromInt(length)); } - -Object* ArrayList::Get(int index) { +Object* ArrayList::Get(int index) const { return FixedArray::cast(this)->get(kFirstIndex + index); } @@ -5673,7 +5671,6 @@ BOOL_ACCESSORS(InterceptorInfo, flags, non_masking, kNonMasking) ACCESSORS(CallHandlerInfo, callback, Object, kCallbackOffset) ACCESSORS(CallHandlerInfo, data, Object, kDataOffset) -ACCESSORS(CallHandlerInfo, fast_handler, Object, kFastHandlerOffset) ACCESSORS(TemplateInfo, tag, Object, kTagOffset) ACCESSORS(TemplateInfo, serial_number, Object, kSerialNumberOffset) diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 9f9a628062b7db..ef84e091dee76b 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -1190,13 +1190,7 @@ Handle FunctionTemplateInfo::GetOrCreateSharedFunctionInfo( Handle name = class_name->IsString() ? Handle::cast(class_name) : isolate->factory()->empty_string(); - Handle code; - if (info->call_code()->IsCallHandlerInfo() && - CallHandlerInfo::cast(info->call_code())->fast_handler()->IsCode()) { - code = isolate->builtins()->HandleFastApiCall(); - } else { - code = isolate->builtins()->HandleApiCall(); - } + Handle code = isolate->builtins()->HandleApiCall(); bool is_constructor = !info->remove_prototype(); Handle result = isolate->factory()->NewSharedFunctionInfo(name, code, is_constructor); @@ -9737,8 +9731,8 @@ void FixedArray::Shrink(int new_length) { } } - -void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, int len) { +void FixedArray::CopyTo(int pos, FixedArray* dest, int dest_pos, + int len) const { DisallowHeapAllocation no_gc; WriteBarrierMode mode = dest->GetWriteBarrierMode(no_gc); for (int index = 0; index < len; index++) { @@ -9899,7 +9893,7 @@ Handle WeakFixedArray::Allocate( return Handle::cast(result); } - +// static Handle ArrayList::Add(Handle array, Handle obj, AddMode mode) { int length = array->Length(); @@ -9913,6 +9907,7 @@ Handle ArrayList::Add(Handle array, Handle obj, return array; } +// static Handle ArrayList::Add(Handle array, Handle obj1, Handle obj2, AddMode mode) { int length = array->Length(); @@ -9926,6 +9921,7 @@ Handle ArrayList::Add(Handle array, Handle obj1, return array; } +// static Handle ArrayList::New(Isolate* isolate, int size) { Handle result = Handle::cast( isolate->factory()->NewFixedArray(size + kFirstIndex)); @@ -9933,6 +9929,7 @@ Handle ArrayList::New(Isolate* isolate, int size) { return result; } + bool ArrayList::IsFull() { int capacity = length(); return kFirstIndex + Length() == capacity; @@ -9956,6 +9953,7 @@ Handle EnsureSpaceInFixedArray(Handle array, } // namespace +// static Handle ArrayList::EnsureSpace(Handle array, int length) { const bool empty = (array->length() == 0); auto ret = Handle::cast( diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index 04d3d384d139e4..0a9680f04c08ab 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -724,7 +724,8 @@ enum InstanceType { JS_MESSAGE_OBJECT_TYPE, JS_DATE_TYPE, // Like JS_OBJECT_TYPE, but created from API function. - JS_API_OBJECT_TYPE, + // We add 3 here for ABI compatibility. + JS_API_OBJECT_TYPE = JS_DATE_TYPE + 3, JS_OBJECT_TYPE, JS_ARGUMENTS_TYPE, JS_CONTEXT_EXTENSION_OBJECT_TYPE, @@ -2768,7 +2769,7 @@ class FixedArray: public FixedArrayBase { void Shrink(int length); // Copy a sub array from the receiver to dest. - void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); + void CopyTo(int pos, FixedArray* dest, int dest_pos, int len) const; // Garbage collection support. static constexpr int SizeFor(int length) { @@ -2941,9 +2942,15 @@ class ArrayList : public FixedArray { static Handle Add(Handle array, Handle obj1, Handle obj2, AddMode = kNone); static Handle New(Isolate* isolate, int size); - inline int Length(); + + // Returns the number of elements in the list, not the allocated size, which + // is length(). Lower and upper case length() return different results! + inline int Length() const; + + // Sets the Length() as used by Elements(). Does not change the underlying + // storage capacity, i.e., length(). inline void SetLength(int length); - inline Object* Get(int index); + inline Object* Get(int index) const; inline Object** Slot(int index); inline void Set(int index, Object* obj, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); @@ -11185,7 +11192,6 @@ class CallHandlerInfo: public Struct { public: DECL_ACCESSORS(callback, Object) DECL_ACCESSORS(data, Object) - DECL_ACCESSORS(fast_handler, Object) DECLARE_CAST(CallHandlerInfo) @@ -11195,8 +11201,7 @@ class CallHandlerInfo: public Struct { static const int kCallbackOffset = HeapObject::kHeaderSize; static const int kDataOffset = kCallbackOffset + kPointerSize; - static const int kFastHandlerOffset = kDataOffset + kPointerSize; - static const int kSize = kFastHandlerOffset + kPointerSize; + static const int kSize = kDataOffset + kPointerSize; private: DISALLOW_IMPLICIT_CONSTRUCTORS(CallHandlerInfo); diff --git a/deps/v8/src/profiler/heap-profiler.cc b/deps/v8/src/profiler/heap-profiler.cc index 938bb1242438fc..d1980d7fa9405b 100644 --- a/deps/v8/src/profiler/heap-profiler.cc +++ b/deps/v8/src/profiler/heap-profiler.cc @@ -201,14 +201,6 @@ void HeapProfiler::UpdateObjectSizeEvent(Address addr, int size) { ids_->UpdateObjectSize(addr, size); } - -void HeapProfiler::SetRetainedObjectInfo(UniqueId id, - RetainedObjectInfo* info) { - // TODO(yurus, marja): Don't route this information through GlobalHandles. - heap()->isolate()->global_handles()->SetRetainedObjectInfo(id, info); -} - - Handle HeapProfiler::FindHeapObjectById(SnapshotObjectId id) { HeapObject* object = NULL; HeapIterator iterator(heap(), HeapIterator::kFilterUnreachable); diff --git a/deps/v8/src/profiler/heap-profiler.h b/deps/v8/src/profiler/heap-profiler.h index a10cb9228fa065..1a43fc8edf2ab0 100644 --- a/deps/v8/src/profiler/heap-profiler.h +++ b/deps/v8/src/profiler/heap-profiler.h @@ -64,7 +64,6 @@ class HeapProfiler { v8::RetainedObjectInfo* ExecuteWrapperClassCallback(uint16_t class_id, Object** wrapper); - void SetRetainedObjectInfo(UniqueId id, RetainedObjectInfo* info); void SetGetRetainerInfosCallback( v8::HeapProfiler::GetRetainerInfosCallback callback); diff --git a/deps/v8/src/v8.gyp b/deps/v8/src/v8.gyp index 144f48285302d3..25d56784c62b82 100644 --- a/deps/v8/src/v8.gyp +++ b/deps/v8/src/v8.gyp @@ -392,7 +392,6 @@ }], 'sources': [ ### gcmole(all) ### '../include/v8-debug.h', - '../include/v8-experimental.h', '../include/v8-platform.h', '../include/v8-profiler.h', '../include/v8-testing.h', @@ -409,8 +408,6 @@ 'allocation.h', 'allocation-site-scopes.cc', 'allocation-site-scopes.h', - 'api-experimental.cc', - 'api-experimental.h', 'api.cc', 'api.h', 'api-arguments-inl.h', @@ -893,8 +890,6 @@ 'external-reference-table.h', 'factory.cc', 'factory.h', - 'fast-accessor-assembler.cc', - 'fast-accessor-assembler.h', 'fast-dtoa.cc', 'fast-dtoa.h', 'feedback-vector-inl.h', diff --git a/deps/v8/test/cctest/BUILD.gn b/deps/v8/test/cctest/BUILD.gn index 1cc0f84167a86c..5cd8132f86e6da 100644 --- a/deps/v8/test/cctest/BUILD.gn +++ b/deps/v8/test/cctest/BUILD.gn @@ -104,7 +104,6 @@ v8_executable("cctest") { "test-accessor-assembler.cc", "test-accessors.cc", "test-api-accessors.cc", - "test-api-fast-accessor-builder.cc", "test-api-interceptors.cc", "test-api.cc", "test-api.h", @@ -159,7 +158,6 @@ v8_executable("cctest") { "test-platform.cc", "test-profile-generator.cc", "test-random-number-generator.cc", - "test-receiver-check-hidden-prototype.cc", "test-regexp.cc", "test-representation.cc", "test-sampler-api.cc", diff --git a/deps/v8/test/cctest/cctest.gyp b/deps/v8/test/cctest/cctest.gyp index 93cbf9edcbd60e..cf51b50ae536f4 100644 --- a/deps/v8/test/cctest/cctest.gyp +++ b/deps/v8/test/cctest/cctest.gyp @@ -128,7 +128,6 @@ 'test-api.h', 'test-api-accessors.cc', 'test-api-interceptors.cc', - 'test-api-fast-accessor-builder.cc', 'test-array-list.cc', 'test-ast.cc', 'test-atomicops.cc', @@ -179,7 +178,6 @@ 'test-platform.cc', 'test-profile-generator.cc', 'test-random-number-generator.cc', - 'test-receiver-check-hidden-prototype.cc', 'test-regexp.cc', 'test-representation.cc', 'test-sampler-api.cc', diff --git a/deps/v8/test/cctest/heap/test-mark-compact.cc b/deps/v8/test/cctest/heap/test-mark-compact.cc index 9f749c5f42f085..342222304b6d62 100644 --- a/deps/v8/test/cctest/heap/test-mark-compact.cc +++ b/deps/v8/test/cctest/heap/test-mark-compact.cc @@ -227,169 +227,12 @@ TEST(MapCompact) { } #endif - -static int NumberOfWeakCalls = 0; -static void WeakPointerCallback(const v8::WeakCallbackInfo& data) { - std::pair*, int>* p = - reinterpret_cast*, int>*>( - data.GetParameter()); - CHECK_EQ(1234, p->second); - NumberOfWeakCalls++; - p->first->Reset(); -} - - -HEAP_TEST(ObjectGroups) { - FLAG_incremental_marking = false; - CcTest::InitializeVM(); - GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); - Heap* heap = CcTest::heap(); - NumberOfWeakCalls = 0; - v8::HandleScope handle_scope(CcTest::isolate()); - - Handle g1s1 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - Handle g1s2 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - Handle g1c1 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - std::pair*, int> g1s1_and_id(&g1s1, 1234); - GlobalHandles::MakeWeak( - g1s1.location(), reinterpret_cast(&g1s1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - std::pair*, int> g1s2_and_id(&g1s2, 1234); - GlobalHandles::MakeWeak( - g1s2.location(), reinterpret_cast(&g1s2_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - std::pair*, int> g1c1_and_id(&g1c1, 1234); - GlobalHandles::MakeWeak( - g1c1.location(), reinterpret_cast(&g1c1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - - Handle g2s1 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - Handle g2s2 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - Handle g2c1 = - global_handles->Create(heap->AllocateFixedArray(1).ToObjectChecked()); - std::pair*, int> g2s1_and_id(&g2s1, 1234); - GlobalHandles::MakeWeak( - g2s1.location(), reinterpret_cast(&g2s1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - std::pair*, int> g2s2_and_id(&g2s2, 1234); - GlobalHandles::MakeWeak( - g2s2.location(), reinterpret_cast(&g2s2_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - std::pair*, int> g2c1_and_id(&g2c1, 1234); - GlobalHandles::MakeWeak( - g2c1.location(), reinterpret_cast(&g2c1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - - Handle root = global_handles->Create(*g1s1); // make a root. - - // Connect group 1 and 2, make a cycle. - Handle::cast(g1s2)->set(0, *g2s2); - Handle::cast(g2s1)->set(0, *g1s1); - - { - Object** g1_objects[] = { g1s1.location(), g1s2.location() }; - Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - global_handles->AddObjectGroup(g1_objects, 2, NULL); - global_handles->SetReference(Handle::cast(g1s1).location(), - g1c1.location()); - global_handles->AddObjectGroup(g2_objects, 2, NULL); - global_handles->SetReference(Handle::cast(g2s1).location(), - g2c1.location()); - } - // Do a full GC - CcTest::CollectGarbage(OLD_SPACE); - - // All object should be alive. - CHECK_EQ(0, NumberOfWeakCalls); - - // Weaken the root. - std::pair*, int> root_and_id(&root, 1234); - GlobalHandles::MakeWeak( - root.location(), reinterpret_cast(&root_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - // But make children strong roots---all the objects (except for children) - // should be collectable now. - global_handles->ClearWeakness(g1c1.location()); - global_handles->ClearWeakness(g2c1.location()); - - // Groups are deleted, rebuild groups. - { - Object** g1_objects[] = { g1s1.location(), g1s2.location() }; - Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - global_handles->AddObjectGroup(g1_objects, 2, NULL); - global_handles->SetReference(Handle::cast(g1s1).location(), - g1c1.location()); - global_handles->AddObjectGroup(g2_objects, 2, NULL); - global_handles->SetReference(Handle::cast(g2s1).location(), - g2c1.location()); - } - - CcTest::CollectGarbage(OLD_SPACE); - - // All objects should be gone. 5 global handles in total. - CHECK_EQ(5, NumberOfWeakCalls); - - // And now make children weak again and collect them. - GlobalHandles::MakeWeak( - g1c1.location(), reinterpret_cast(&g1c1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - GlobalHandles::MakeWeak( - g2c1.location(), reinterpret_cast(&g2c1_and_id), - &WeakPointerCallback, v8::WeakCallbackType::kParameter); - - CcTest::CollectGarbage(OLD_SPACE); - CHECK_EQ(7, NumberOfWeakCalls); -} - - -class TestRetainedObjectInfo : public v8::RetainedObjectInfo { - public: - TestRetainedObjectInfo() : has_been_disposed_(false) {} - - bool has_been_disposed() { return has_been_disposed_; } - - virtual void Dispose() { - CHECK(!has_been_disposed_); - has_been_disposed_ = true; - } - - virtual bool IsEquivalent(v8::RetainedObjectInfo* other) { - return other == this; - } - - virtual intptr_t GetHash() { return 0; } - - virtual const char* GetLabel() { return "whatever"; } - - private: - bool has_been_disposed_; -}; - - -TEST(EmptyObjectGroups) { - CcTest::InitializeVM(); - GlobalHandles* global_handles = CcTest::i_isolate()->global_handles(); - - v8::HandleScope handle_scope(CcTest::isolate()); - - TestRetainedObjectInfo info; - global_handles->AddObjectGroup(NULL, 0, &info); - CHECK(info.has_been_disposed()); -} - - #if defined(__has_feature) #if __has_feature(address_sanitizer) #define V8_WITH_ASAN 1 #endif #endif - // Here is a memory use test that uses /proc, and is therefore Linux-only. We // do not care how much memory the simulator uses, since it is only there for // debugging purposes. Testing with ASAN doesn't make sense, either. diff --git a/deps/v8/test/cctest/test-api-accessors.cc b/deps/v8/test/cctest/test-api-accessors.cc index 921f54d466a53d..85fb3bd93c5df3 100644 --- a/deps/v8/test/cctest/test-api-accessors.cc +++ b/deps/v8/test/cctest/test-api-accessors.cc @@ -4,115 +4,12 @@ #include "test/cctest/cctest.h" -#include "include/v8-experimental.h" #include "include/v8.h" #include "src/api.h" #include "src/objects-inl.h" namespace i = v8::internal; -static void CppAccessor42(const v8::FunctionCallbackInfo& info) { - info.GetReturnValue().Set(42); -} - - -static void CppAccessor41(const v8::FunctionCallbackInfo& info) { - info.GetReturnValue().Set(41); -} - - -v8::experimental::FastAccessorBuilder* FastAccessor(v8::Isolate* isolate) { - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - builder->ReturnValue(builder->IntegerConstant(41)); - return builder; -} - - -TEST(FastAccessors) { - v8::Isolate* isolate = CcTest::isolate(); - v8::HandleScope scope(isolate); - LocalContext env; - - // We emulate Embedder-created DOM Node instances. Specifically: - // - 'parent': FunctionTemplate ~= DOM Node superclass - // - 'child': FunctionTemplate ~= a specific DOM node type, like a
- // - // We'll install both a C++-based and a JS-based accessor on the parent, - // and expect it to be callable on the child. - - // Setup the parent template ( =~ DOM Node w/ accessors). - v8::Local parent = v8::FunctionTemplate::New(isolate); - { - auto signature = v8::Signature::New(isolate, parent); - - // cpp accessor as "firstChild": - parent->PrototypeTemplate()->SetAccessorProperty( - v8_str("firstChild"), - v8::FunctionTemplate::New(isolate, CppAccessor42, - v8::Local(), signature)); - - // JS accessor as "firstChildRaw": - parent->PrototypeTemplate()->SetAccessorProperty( - v8_str("firstChildRaw"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, CppAccessor41, FastAccessor(isolate), - v8::Local(), signature)); - } - - // Setup child object ( =~ a specific DOM Node, e.g. a
). - // Also, make a creation function on the global object, so we can access it - // in a test. - v8::Local child = v8::FunctionTemplate::New(isolate); - child->Inherit(parent); - CHECK(env->Global() - ->Set(env.local(), v8_str("Node"), - child->GetFunction(env.local()).ToLocalChecked()) - .IsJust()); - - // Setup done: Let's test it: - - // The simple case: Run it once. - ExpectInt32("var n = new Node(); n.firstChild", 42); - ExpectInt32("var n = new Node(); n.firstChildRaw", 41); - - // Run them in a loop. This will likely trigger the optimizing compiler: - ExpectInt32( - "var m = new Node(); " - "var sum = 0; " - "for (var i = 0; i < 10; ++i) { " - " sum += m.firstChild; " - " sum += m.firstChildRaw; " - "}; " - "sum;", - 10 * (42 + 41)); - - // Obtain the accessor and call it via apply on the Node: - ExpectInt32( - "var n = new Node(); " - "var g = Object.getOwnPropertyDescriptor(" - " n.__proto__.__proto__, 'firstChild')['get']; " - "g.apply(n);", - 42); - ExpectInt32( - "var n = new Node(); " - "var g = Object.getOwnPropertyDescriptor(" - " n.__proto__.__proto__, 'firstChildRaw')['get']; " - "g.apply(n);", - 41); - - ExpectInt32( - "var n = new Node();" - "var g = Object.getOwnPropertyDescriptor(" - " n.__proto__.__proto__, 'firstChildRaw')['get'];" - "try {" - " var f = { firstChildRaw: '51' };" - " g.apply(f);" - "} catch(e) {" - " 31415;" - "}", - 31415); -} - // The goal is to avoid the callback. static void UnreachableCallback( const v8::FunctionCallbackInfo& info) { diff --git a/deps/v8/test/cctest/test-api-fast-accessor-builder.cc b/deps/v8/test/cctest/test-api-fast-accessor-builder.cc deleted file mode 100644 index 8b85e2aa34e664..00000000000000 --- a/deps/v8/test/cctest/test-api-fast-accessor-builder.cc +++ /dev/null @@ -1,492 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include - -#include "include/v8.h" -#include "include/v8-experimental.h" - -#include "src/api.h" -#include "src/objects-inl.h" -#include "test/cctest/cctest.h" - -namespace { - -// These tests mean to exercise v8::FastAccessorBuilder. Since initially the -// "native" accessor will get called, we need to "warmup" any accessor first, -// to make sure we're actually testing the v8::FastAccessorBuilder result. -// To accomplish this, we will -// - call each accesssor N times before the actual test. -// - wrap that call in a function, so that all such calls will go -// through a single call site. -// - bloat that function with a very long comment to prevent its inlining. -// - register a native accessor which is different from the build one -// (so that our tests will always fail if we don't end up in the 'fast' -// accessor). -// -// FN_WARMUP(name, src) define a JS function "name" with body "src". -// It adds the INLINE_SPOILER to prevent inlining and will call name() -// repeatedly to guarantee it's "warm". -// -// Use: -// CompileRun(FN_WARMUP("fn", "return something();")); -// ExpectXXX("fn(1234)", 5678); - -#define INLINE_SPOILER \ - " /* " \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \ - "*/ " // 16 lines * 64 'X' =~ 1024 character comment. -#define FN(name, src) "function " name "() { " src INLINE_SPOILER " }" -#define WARMUP(name, count) "for(i = 0; i < " count "; i++) { " name "() } " -#define FN_WARMUP(name, src) FN(name, src) "; " WARMUP(name, "2") - -static void NativePropertyAccessor( - const v8::FunctionCallbackInfo& info) { - info.GetReturnValue().Set(v8_num(123)); -} - -const char* kWatermarkProperty = "watermark"; - -} // anonymous namespace - -void CheckImplicitParameters(const v8::FunctionCallbackInfo& info) { - v8::Isolate* isolate = info.GetIsolate(); - CHECK_NOT_NULL(isolate); - - auto context = isolate->GetCurrentContext(); - CHECK(!context.IsEmpty()); - - // The context must point to the same isolate, this should be enough to - // validate the context, mainly to prevent having a random object instead. - CHECK_EQ(isolate, context->GetIsolate()); - CHECK(info.Data()->IsUndefined()); - - CHECK(info.Holder()->Has(context, v8_str(kWatermarkProperty)).FromJust()); -} - -// Build a simple "fast accessor" and verify that it is being called. -TEST(FastAccessor) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::FunctionTemplate::New(isolate); - - // Native accessor, bar, returns 123. - foo->PrototypeTemplate()->SetAccessorProperty( - v8_str("bar"), - v8::FunctionTemplate::New(isolate, NativePropertyAccessor)); - - // Fast accessor, barf, returns 124. - auto fab = v8::experimental::FastAccessorBuilder::New(isolate); - fab->ReturnValue(fab->IntegerConstant(124)); - foo->PrototypeTemplate()->SetAccessorProperty( - v8_str("barf"), v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, fab)); - - // Install foo on the global object. - CHECK(env->Global() - ->Set(env.local(), v8_str("foo"), - foo->GetFunction(env.local()).ToLocalChecked()) - .FromJust()); - - // Wrap f.barf + IC warmup. - CompileRun(FN_WARMUP("barf", "f = new foo(); return f.barf")); - - ExpectInt32("f = new foo(); f.bar", 123); - ExpectInt32("f = new foo(); f.barf", 123); // First call in this call site. - ExpectInt32("barf()", 124); // Call via warmed-up callsite. -} - -void AddInternalFieldAccessor(v8::Isolate* isolate, - v8::Local templ, const char* name, - int field_no, bool useUncheckedLoader) { - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - - if (useUncheckedLoader) { - builder->ReturnValue( - builder->LoadInternalFieldUnchecked(builder->GetReceiver(), field_no)); - } else { - builder->ReturnValue( - builder->LoadInternalField(builder->GetReceiver(), field_no)); - } - - templ->SetAccessorProperty(v8_str(name), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); -} - -void checkLoadInternalField(bool useUncheckedLoader, bool emitDebugChecks) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - - // De/activate debug checks. - v8::internal::FLAG_debug_code = emitDebugChecks; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(3); - AddInternalFieldAccessor(isolate, foo, "field0", 0, useUncheckedLoader); - AddInternalFieldAccessor(isolate, foo, "field1", 1, useUncheckedLoader); - AddInternalFieldAccessor(isolate, foo, "field2", 2, useUncheckedLoader); - - // Create an instance w/ 3 internal fields, put in a string, a Smi, nothing. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - obj->SetInternalField(0, v8_str("Hi there!")); - obj->SetInternalField(1, v8::Integer::New(isolate, 4321)); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // Warmup. - CompileRun(FN_WARMUP("field0", "return obj.field0")); - CompileRun(FN_WARMUP("field1", "return obj.field1")); - CompileRun(FN_WARMUP("field2", "return obj.field2")); - - // Access fields. - ExpectString("field0()", "Hi there!"); - ExpectInt32("field1()", 4321); - ExpectUndefined("field2()"); -} - -// "Fast" accessor that accesses an internal field. -TEST(FastAccessorWithInternalField) { checkLoadInternalField(false, false); } - -// "Fast" accessor that accesses an internal field using the fast(er) -// implementation of LoadInternalField. -TEST(FastAccessorLoadInternalFieldUnchecked) { - checkLoadInternalField(true, false); - checkLoadInternalField(true, true); -} - -// "Fast" accessor with control flow via ...OrReturnNull methods. -TEST(FastAccessorOrReturnNull) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(2); - { - // accessor "nullcheck": Return null if field 0 is non-null object; else 5. - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - auto val = builder->LoadInternalField(builder->GetReceiver(), 0); - builder->CheckNotZeroOrReturnNull(val); - builder->ReturnValue(builder->IntegerConstant(5)); - foo->SetAccessorProperty(v8_str("nullcheck"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - { - // accessor "maskcheck": Return null if field 1 has 3rd bit set. - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - auto val = builder->LoadInternalField(builder->GetReceiver(), 1); - builder->CheckFlagSetOrReturnNull(val, 0x4); - builder->ReturnValue(builder->IntegerConstant(42)); - foo->SetAccessorProperty(v8_str("maskcheck"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // CheckNotZeroOrReturnNull: - CompileRun(FN_WARMUP("nullcheck", "return obj.nullcheck")); - obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate); - ExpectInt32("nullcheck()", 5); - obj->SetAlignedPointerInInternalField(0, nullptr); - ExpectNull("nullcheck()"); - - // CheckFlagSetOrReturnNull: - CompileRun(FN_WARMUP("maskcheck", "return obj.maskcheck")); - obj->SetAlignedPointerInInternalField(1, reinterpret_cast(0xf0)); - ExpectNull("maskcheck()"); - obj->SetAlignedPointerInInternalField(1, reinterpret_cast(0xfe)); - ExpectInt32("maskcheck()", 42); -} - - -// "Fast" accessor with simple control flow via explicit labels. -TEST(FastAccessorControlFlowWithLabels) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(1); - { - // accessor isnull: 0 for nullptr, else 1. - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - auto label = builder->MakeLabel(); - auto val = builder->LoadInternalField(builder->GetReceiver(), 0); - builder->CheckNotZeroOrJump(val, label); - builder->ReturnValue(builder->IntegerConstant(1)); - builder->SetLabel(label); - builder->ReturnValue(builder->IntegerConstant(0)); - foo->SetAccessorProperty(v8_str("isnull"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // CheckNotZeroOrReturnNull: - CompileRun(FN_WARMUP("isnull", "return obj.isnull")); - obj->SetAlignedPointerInInternalField(0, /* anything != nullptr */ isolate); - ExpectInt32("isnull()", 1); - obj->SetAlignedPointerInInternalField(0, nullptr); - ExpectInt32("isnull()", 0); -} - - -// "Fast" accessor, loading things. -TEST(FastAccessorLoad) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(1); - - // Internal field 0 is a pointer to a C++ data structure that we wish to load - // field values from. - struct { - size_t intval; - v8::Local v8val; - } val = {54321, v8_str("Hello")}; - - { - // accessor intisnonzero - int intval_offset = - static_cast(reinterpret_cast(&val.intval) - - reinterpret_cast(&val)); - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - auto label = builder->MakeLabel(); - auto val = builder->LoadValue( - builder->LoadInternalField(builder->GetReceiver(), 0), intval_offset); - builder->CheckNotZeroOrJump(val, label); - builder->ReturnValue(builder->IntegerConstant(1)); - builder->SetLabel(label); - builder->ReturnValue(builder->IntegerConstant(0)); - foo->SetAccessorProperty(v8_str("nonzero"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - { - // accessor loadval - int v8val_offset = static_cast(reinterpret_cast(&val.v8val) - - reinterpret_cast(&val)); - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - builder->ReturnValue(builder->LoadObject( - builder->LoadInternalField(builder->GetReceiver(), 0), v8val_offset)); - foo->SetAccessorProperty(v8_str("loadval"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - obj->SetAlignedPointerInInternalField(0, &val); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // Access val.intval: - CompileRun(FN_WARMUP("nonzero", "return obj.nonzero")); - ExpectInt32("nonzero()", 1); - val.intval = 0; - ExpectInt32("nonzero()", 0); - val.intval = 27; - ExpectInt32("nonzero()", 1); - - // Access val.v8val: - CompileRun(FN_WARMUP("loadval", "return obj.loadval")); - ExpectString("loadval()", "Hello"); -} - -void ApiCallbackInt(const v8::FunctionCallbackInfo& info) { - CheckImplicitParameters(info); - info.GetReturnValue().Set(12345); -} - -const char* kApiCallbackStringValue = - "Hello World! Bizarro C++ world, actually."; -void ApiCallbackString(const v8::FunctionCallbackInfo& info) { - CheckImplicitParameters(info); - info.GetReturnValue().Set(v8_str(kApiCallbackStringValue)); -} - -void ApiCallbackParam(const v8::FunctionCallbackInfo& info) { - CheckImplicitParameters(info); - CHECK_EQ(1, info.Length()); - CHECK(info[0]->IsNumber()); - info.GetReturnValue().Set(info[0]); -} - -// "Fast" accessor, callback to embedder -TEST(FastAccessorCallback) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - { - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - builder->ReturnValue( - builder->Call(&ApiCallbackInt, builder->IntegerConstant(999))); - foo->SetAccessorProperty(v8_str("int"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - - builder = v8::experimental::FastAccessorBuilder::New(isolate); - builder->ReturnValue( - builder->Call(&ApiCallbackString, builder->IntegerConstant(0))); - foo->SetAccessorProperty(v8_str("str"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - - builder = v8::experimental::FastAccessorBuilder::New(isolate); - builder->ReturnValue( - builder->Call(&ApiCallbackParam, builder->IntegerConstant(1000))); - foo->SetAccessorProperty(v8_str("param"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Add dummy property to validate the holder. - foo->Set(isolate, kWatermarkProperty, v8::Undefined(isolate)); - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // Callbacks: - CompileRun(FN_WARMUP("callbackint", "return obj.int")); - ExpectInt32("callbackint()", 12345); - - CompileRun(FN_WARMUP("callbackstr", "return obj.str")); - ExpectString("callbackstr()", kApiCallbackStringValue); - - CompileRun(FN_WARMUP("callbackparam", "return obj.param")); - ExpectInt32("callbackparam()", 1000); -} - -TEST(FastAccessorToSmi) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(1); - - { - // Accessor load_smi. - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - - // Read the variable and convert it to a Smi. - auto flags = builder->LoadValue( - builder->LoadInternalField(builder->GetReceiver(), 0), 0); - builder->ReturnValue(builder->ToSmi(flags)); - foo->SetAccessorProperty(v8_str("load_smi"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - - uintptr_t flags; - obj->SetAlignedPointerInInternalField(0, &flags); - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // Access flags. - CompileRun(FN_WARMUP("load_smi", "return obj.load_smi")); - - flags = 54321; - ExpectInt32("load_smi()", 54321); - - flags = 0; - ExpectInt32("load_smi()", 0); - - flags = 123456789; - ExpectInt32("load_smi()", 123456789); -} - -TEST(FastAccessorGoto) { - // Crankshaft support for fast accessors is not implemented; crankshafted - // code uses the slow accessor which breaks this test's expectations. - v8::internal::FLAG_always_opt = false; - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - - v8::Local foo = v8::ObjectTemplate::New(isolate); - foo->SetInternalFieldCount(1); - - { - auto builder = v8::experimental::FastAccessorBuilder::New(isolate); - auto successLabel = builder->MakeLabel(); - auto failLabel = builder->MakeLabel(); - - // The underlying raw assembler is clever enough to reject unreachable - // basic blocks, this instruction has no effect besides marking the failed - // return BB as reachable. - builder->CheckNotZeroOrJump(builder->IntegerConstant(1234), failLabel); - - builder->Goto(successLabel); - - builder->SetLabel(failLabel); - builder->ReturnValue(builder->IntegerConstant(0)); - - builder->SetLabel(successLabel); - builder->ReturnValue(builder->IntegerConstant(60707357)); - - foo->SetAccessorProperty(v8_str("goto_test"), - v8::FunctionTemplate::NewWithFastHandler( - isolate, NativePropertyAccessor, builder)); - } - - // Create an instance. - v8::Local obj = foo->NewInstance(env.local()).ToLocalChecked(); - - CHECK(env->Global()->Set(env.local(), v8_str("obj"), obj).FromJust()); - - // Access flags. - CompileRun(FN_WARMUP("test", "return obj.goto_test")); - - ExpectInt32("test()", 60707357); -} diff --git a/deps/v8/test/cctest/test-global-handles.cc b/deps/v8/test/cctest/test-global-handles.cc index 2ace0296c1e5bd..648cd869630e47 100644 --- a/deps/v8/test/cctest/test-global-handles.cc +++ b/deps/v8/test/cctest/test-global-handles.cc @@ -36,295 +36,6 @@ using namespace v8::internal; using v8::UniqueId; - -static List skippable_objects; -static List can_skip_called_objects; - - -static bool CanSkipCallback(Heap* heap, Object** pointer) { - can_skip_called_objects.Add(*pointer); - return skippable_objects.Contains(*pointer); -} - - -static void ResetCanSkipData() { - skippable_objects.Clear(); - can_skip_called_objects.Clear(); -} - - -class TestRetainedObjectInfo : public v8::RetainedObjectInfo { - public: - TestRetainedObjectInfo() : has_been_disposed_(false) {} - - bool has_been_disposed() { return has_been_disposed_; } - - virtual void Dispose() { - CHECK(!has_been_disposed_); - has_been_disposed_ = true; - } - - virtual bool IsEquivalent(v8::RetainedObjectInfo* other) { - return other == this; - } - - virtual intptr_t GetHash() { return 0; } - - virtual const char* GetLabel() { return "whatever"; } - - private: - bool has_been_disposed_; -}; - - -class TestObjectVisitor : public ObjectVisitor { - public: - void VisitPointers(Object** start, Object** end) override { - for (Object** o = start; o != end; ++o) - visited.Add(*o); - } - - List visited; -}; - - -TEST(IterateObjectGroupsOldApi) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - GlobalHandles* global_handles = isolate->global_handles(); - v8::HandleScope handle_scope(CcTest::isolate()); - - Handle g1s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g1s2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - Handle g2s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g2s2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - TestRetainedObjectInfo info1; - TestRetainedObjectInfo info2; - { - Object** g1_objects[] = { g1s1.location(), g1s2.location() }; - Object** g2_objects[] = { g2s1.location(), g2s2.location() }; - - global_handles->AddObjectGroup(g1_objects, 2, &info1); - global_handles->AddObjectGroup(g2_objects, 2, &info2); - } - - // Iterate the object groups. First skip all. - { - ResetCanSkipData(); - skippable_objects.Add(*g1s1.location()); - skippable_objects.Add(*g1s2.location()); - skippable_objects.Add(*g2s1.location()); - skippable_objects.Add(*g2s2.location()); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 4); - CHECK(can_skip_called_objects.Contains(*g1s1.location())); - CHECK(can_skip_called_objects.Contains(*g1s2.location())); - CHECK(can_skip_called_objects.Contains(*g2s1.location())); - CHECK(can_skip_called_objects.Contains(*g2s2.location())); - - // Nothing was visited. - CHECK(visitor.visited.length() == 0); - CHECK(!info1.has_been_disposed()); - CHECK(!info2.has_been_disposed()); - } - - // Iterate again, now only skip the second object group. - { - ResetCanSkipData(); - // The first grough should still be visited, since only one object is - // skipped. - skippable_objects.Add(*g1s1.location()); - skippable_objects.Add(*g2s1.location()); - skippable_objects.Add(*g2s2.location()); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 3 || - can_skip_called_objects.length() == 4); - CHECK(can_skip_called_objects.Contains(*g1s2.location())); - CHECK(can_skip_called_objects.Contains(*g2s1.location())); - CHECK(can_skip_called_objects.Contains(*g2s2.location())); - - // The first group was visited. - CHECK(visitor.visited.length() == 2); - CHECK(visitor.visited.Contains(*g1s1.location())); - CHECK(visitor.visited.Contains(*g1s2.location())); - CHECK(info1.has_been_disposed()); - CHECK(!info2.has_been_disposed()); - } - - // Iterate again, don't skip anything. - { - ResetCanSkipData(); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 1); - CHECK(can_skip_called_objects.Contains(*g2s1.location()) || - can_skip_called_objects.Contains(*g2s2.location())); - - // The second group was visited. - CHECK(visitor.visited.length() == 2); - CHECK(visitor.visited.Contains(*g2s1.location())); - CHECK(visitor.visited.Contains(*g2s2.location())); - CHECK(info2.has_been_disposed()); - } -} - - -TEST(IterateObjectGroups) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - GlobalHandles* global_handles = isolate->global_handles(); - - v8::HandleScope handle_scope(CcTest::isolate()); - - Handle g1s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g1s2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - Handle g2s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g2s2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - TestRetainedObjectInfo info1; - TestRetainedObjectInfo info2; - global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); - global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); - global_handles->SetRetainedObjectInfo(UniqueId(2), &info2); - global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); - global_handles->SetObjectGroupId(g1s2.location(), UniqueId(1)); - global_handles->SetRetainedObjectInfo(UniqueId(1), &info1); - - // Iterate the object groups. First skip all. - { - ResetCanSkipData(); - skippable_objects.Add(*g1s1.location()); - skippable_objects.Add(*g1s2.location()); - skippable_objects.Add(*g2s1.location()); - skippable_objects.Add(*g2s2.location()); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 4); - CHECK(can_skip_called_objects.Contains(*g1s1.location())); - CHECK(can_skip_called_objects.Contains(*g1s2.location())); - CHECK(can_skip_called_objects.Contains(*g2s1.location())); - CHECK(can_skip_called_objects.Contains(*g2s2.location())); - - // Nothing was visited. - CHECK(visitor.visited.length() == 0); - CHECK(!info1.has_been_disposed()); - CHECK(!info2.has_been_disposed()); - } - - // Iterate again, now only skip the second object group. - { - ResetCanSkipData(); - // The first grough should still be visited, since only one object is - // skipped. - skippable_objects.Add(*g1s1.location()); - skippable_objects.Add(*g2s1.location()); - skippable_objects.Add(*g2s2.location()); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 3 || - can_skip_called_objects.length() == 4); - CHECK(can_skip_called_objects.Contains(*g1s2.location())); - CHECK(can_skip_called_objects.Contains(*g2s1.location())); - CHECK(can_skip_called_objects.Contains(*g2s2.location())); - - // The first group was visited. - CHECK(visitor.visited.length() == 2); - CHECK(visitor.visited.Contains(*g1s1.location())); - CHECK(visitor.visited.Contains(*g1s2.location())); - CHECK(info1.has_been_disposed()); - CHECK(!info2.has_been_disposed()); - } - - // Iterate again, don't skip anything. - { - ResetCanSkipData(); - TestObjectVisitor visitor; - global_handles->IterateObjectGroups(&visitor, &CanSkipCallback); - - // CanSkipCallback was called for all objects. - CHECK(can_skip_called_objects.length() == 1); - CHECK(can_skip_called_objects.Contains(*g2s1.location()) || - can_skip_called_objects.Contains(*g2s2.location())); - - // The second group was visited. - CHECK(visitor.visited.length() == 2); - CHECK(visitor.visited.Contains(*g2s1.location())); - CHECK(visitor.visited.Contains(*g2s2.location())); - CHECK(info2.has_been_disposed()); - } -} - - -TEST(ImplicitReferences) { - CcTest::InitializeVM(); - Isolate* isolate = CcTest::i_isolate(); - GlobalHandles* global_handles = isolate->global_handles(); - - v8::HandleScope handle_scope(CcTest::isolate()); - - Handle g1s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g1c1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g1c2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - - Handle g2s1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g2s2 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - Handle g2c1 = - global_handles->Create(*isolate->factory()->NewFixedArray(1)); - - global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1)); - global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2)); - global_handles->SetObjectGroupId(g2s2.location(), UniqueId(2)); - global_handles->SetReferenceFromGroup(UniqueId(1), g1c1.location()); - global_handles->SetReferenceFromGroup(UniqueId(1), g1c2.location()); - global_handles->SetReferenceFromGroup(UniqueId(2), g2c1.location()); - - List* implicit_refs = - global_handles->implicit_ref_groups(); - USE(implicit_refs); - CHECK(implicit_refs->length() == 2); - CHECK(implicit_refs->at(0)->parent == - reinterpret_cast(g1s1.location())); - CHECK(implicit_refs->at(0)->length == 2); - CHECK(implicit_refs->at(0)->children[0] == g1c1.location()); - CHECK(implicit_refs->at(0)->children[1] == g1c2.location()); - CHECK(implicit_refs->at(1)->parent == - reinterpret_cast(g2s1.location())); - CHECK(implicit_refs->at(1)->length == 1); - CHECK(implicit_refs->at(1)->children[0] == g2c1.location()); - global_handles->RemoveObjectGroups(); - global_handles->RemoveImplicitRefGroups(); -} - - TEST(EternalHandles) { CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); diff --git a/deps/v8/test/cctest/test-receiver-check-hidden-prototype.cc b/deps/v8/test/cctest/test-receiver-check-hidden-prototype.cc deleted file mode 100644 index 90ed8e7b56d724..00000000000000 --- a/deps/v8/test/cctest/test-receiver-check-hidden-prototype.cc +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include - -#include "include/v8-experimental.h" -#include "src/v8.h" -#include "test/cctest/cctest.h" - -namespace { - - -static void SlowCallback(const v8::FunctionCallbackInfo& info) { - info.GetReturnValue().Set(41); -} - - -TEST(CompatibleReceiverBuiltin) { - // Check that the HandleFastApiCall builtin visits the hidden prototypes - // during the compatible receiver check. - LocalContext context; - v8::Isolate* isolate = context->GetIsolate(); - v8::HandleScope handle_scope(isolate); - v8::Local current_context = isolate->GetCurrentContext(); - - v8::Local constructor_template = - v8::FunctionTemplate::New(isolate); - v8::Local prototype_template = - v8::FunctionTemplate::New(isolate); - prototype_template->SetHiddenPrototype(true); - - v8::Local proto_instance_template = - prototype_template->InstanceTemplate(); - - v8::experimental::FastAccessorBuilder* fast_accessor_builder = - v8::experimental::FastAccessorBuilder::New(isolate); - fast_accessor_builder->ReturnValue( - fast_accessor_builder->IntegerConstant(42)); - v8::Local accessor_template = - v8::FunctionTemplate::NewWithFastHandler( - isolate, SlowCallback, fast_accessor_builder, v8::Local(), - v8::Signature::New(isolate, prototype_template)); - - proto_instance_template->SetAccessorProperty( - v8_str("bar"), accessor_template, v8::Local(), - v8::ReadOnly); - - v8::Local object = - constructor_template->GetFunction(current_context) - .ToLocalChecked() - ->NewInstance(current_context) - .ToLocalChecked(); - - v8::Local hidden_prototype = - prototype_template->GetFunction(current_context) - .ToLocalChecked() - ->NewInstance(current_context) - .ToLocalChecked(); - - CHECK(object->SetPrototype(current_context, hidden_prototype).FromJust()); - - context->Global() - ->Set(current_context, v8_str("object"), object) - .FromMaybe(false); - - CHECK_EQ(42, CompileRun("var getter = object.__lookupGetter__('bar');" - "getter.call(object)") - ->Int32Value(current_context) - .FromJust()); -} - -} // namespace diff --git a/deps/v8/test/fuzzer/fuzzer-support.cc b/deps/v8/test/fuzzer/fuzzer-support.cc index 936970ee6a75de..0e268fba8180e8 100644 --- a/deps/v8/test/fuzzer/fuzzer-support.cc +++ b/deps/v8/test/fuzzer/fuzzer-support.cc @@ -75,7 +75,7 @@ FuzzerSupport::~FuzzerSupport() { // static FuzzerSupport* FuzzerSupport::Get() { return g_fuzzer_support; } -v8::Isolate* FuzzerSupport::GetIsolate() { return isolate_; } +v8::Isolate* FuzzerSupport::GetIsolate() const { return isolate_; } v8::Local FuzzerSupport::GetContext() { v8::Isolate::Scope isolate_scope(isolate_); diff --git a/deps/v8/test/fuzzer/fuzzer-support.h b/deps/v8/test/fuzzer/fuzzer-support.h index c941c9c0520418..62bc4fa7cd7b38 100644 --- a/deps/v8/test/fuzzer/fuzzer-support.h +++ b/deps/v8/test/fuzzer/fuzzer-support.h @@ -16,7 +16,7 @@ class FuzzerSupport { static FuzzerSupport* Get(); - v8::Isolate* GetIsolate(); + v8::Isolate* GetIsolate() const; v8::Local GetContext(); private: diff --git a/deps/v8/test/unittests/object-unittest.cc b/deps/v8/test/unittests/object-unittest.cc index b09b97dea6991f..2888480d812ced 100644 --- a/deps/v8/test/unittests/object-unittest.cc +++ b/deps/v8/test/unittests/object-unittest.cc @@ -23,7 +23,8 @@ TEST(Object, InstanceTypeListOrder) { #define TEST_INSTANCE_TYPE(type) \ current_type = InstanceType::type; \ current = static_cast(current_type); \ - if (current > static_cast(LAST_NAME_TYPE)) { \ + if (current > static_cast(LAST_NAME_TYPE) && \ + current != JS_API_OBJECT_TYPE) { \ EXPECT_EQ(last + 1, current); \ } \ EXPECT_LT(last, current) << " INSTANCE_TYPE_LIST is not ordered: " \