| Index: src/objects.cc
|
| ===================================================================
|
| --- src/objects.cc (revision 7267)
|
| +++ src/objects.cc (working copy)
|
| @@ -51,7 +51,6 @@
|
| #include "disassembler.h"
|
| #endif
|
|
|
| -
|
| namespace v8 {
|
| namespace internal {
|
|
|
| @@ -64,7 +63,8 @@
|
| MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
|
| Object* value) {
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateJSObject(constructor);
|
| + { MaybeObject* maybe_result =
|
| + constructor->GetHeap()->AllocateJSObject(constructor);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| JSValue::cast(result)->set_value(value);
|
| @@ -86,14 +86,19 @@
|
|
|
|
|
| MaybeObject* Object::ToObject() {
|
| - Context* global_context = Top::context()->global_context();
|
| if (IsJSObject()) {
|
| return this;
|
| } else if (IsNumber()) {
|
| + Isolate* isolate = Isolate::Current();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->number_function(), this);
|
| } else if (IsBoolean()) {
|
| + Isolate* isolate = HeapObject::cast(this)->GetIsolate();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->boolean_function(), this);
|
| } else if (IsString()) {
|
| + Isolate* isolate = HeapObject::cast(this)->GetIsolate();
|
| + Context* global_context = isolate->context()->global_context();
|
| return CreateJSValue(global_context->string_function(), this);
|
| }
|
|
|
| @@ -103,35 +108,43 @@
|
|
|
|
|
| Object* Object::ToBoolean() {
|
| - if (IsTrue()) return Heap::true_value();
|
| - if (IsFalse()) return Heap::false_value();
|
| + if (IsTrue()) return this;
|
| + if (IsFalse()) return this;
|
| if (IsSmi()) {
|
| - return Heap::ToBoolean(Smi::cast(this)->value() != 0);
|
| + return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0);
|
| }
|
| - if (IsUndefined() || IsNull()) return Heap::false_value();
|
| + if (IsUndefined() || IsNull()) {
|
| + return HeapObject::cast(this)->GetHeap()->false_value();
|
| + }
|
| // Undetectable object is false
|
| if (IsUndetectableObject()) {
|
| - return Heap::false_value();
|
| + return HeapObject::cast(this)->GetHeap()->false_value();
|
| }
|
| if (IsString()) {
|
| - return Heap::ToBoolean(String::cast(this)->length() != 0);
|
| + return HeapObject::cast(this)->GetHeap()->ToBoolean(
|
| + String::cast(this)->length() != 0);
|
| }
|
| if (IsHeapNumber()) {
|
| return HeapNumber::cast(this)->HeapNumberToBoolean();
|
| }
|
| - return Heap::true_value();
|
| + return Isolate::Current()->heap()->true_value();
|
| }
|
|
|
|
|
| void Object::Lookup(String* name, LookupResult* result) {
|
| if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result);
|
| Object* holder = NULL;
|
| - Context* global_context = Top::context()->global_context();
|
| if (IsString()) {
|
| + Heap* heap = HeapObject::cast(this)->GetHeap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->string_function()->instance_prototype();
|
| } else if (IsNumber()) {
|
| + Heap* heap = Isolate::Current()->heap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->number_function()->instance_prototype();
|
| } else if (IsBoolean()) {
|
| + Heap* heap = HeapObject::cast(this)->GetHeap();
|
| + Context* global_context = heap->isolate()->context()->global_context();
|
| holder = global_context->boolean_function()->instance_prototype();
|
| }
|
| ASSERT(holder != NULL); // Cannot handle null or undefined.
|
| @@ -154,6 +167,7 @@
|
| Object* structure,
|
| String* name,
|
| Object* holder) {
|
| + Isolate* isolate = name->GetIsolate();
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| // callbacks should be phased out.
|
| @@ -161,7 +175,7 @@
|
| AccessorDescriptor* callback =
|
| reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
|
| MaybeObject* value = (callback->getter)(receiver, callback->data);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return value;
|
| }
|
|
|
| @@ -174,17 +188,19 @@
|
| JSObject* self = JSObject::cast(receiver);
|
| JSObject* holder_handle = JSObject::cast(holder);
|
| Handle<String> key(name);
|
| - LOG(ApiNamedPropertyAccess("load", self, name));
|
| - CustomArguments args(data->data(), self, holder_handle);
|
| + LOG(isolate, ApiNamedPropertyAccess("load", self, name));
|
| + CustomArguments args(isolate, data->data(), self, holder_handle);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = call_fun(v8::Utils::ToLocal(key), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| - if (result.IsEmpty()) return Heap::undefined_value();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| + if (result.IsEmpty()) {
|
| + return isolate->heap()->undefined_value();
|
| + }
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| @@ -196,7 +212,7 @@
|
| JSFunction::cast(getter));
|
| }
|
| // Getter is not a function.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| UNREACHABLE();
|
| @@ -210,9 +226,10 @@
|
| Handle<JSFunction> fun(JSFunction::cast(getter));
|
| Handle<Object> self(receiver);
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| + Debug* debug = fun->GetHeap()->isolate()->debug();
|
| // Handle stepping into a getter if step into is active.
|
| - if (Debug::StepInActive()) {
|
| - Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| + if (debug->StepInActive()) {
|
| + debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| }
|
| #endif
|
| bool has_pending_exception;
|
| @@ -230,6 +247,7 @@
|
| LookupResult* result,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = name->GetHeap();
|
| if (result->IsProperty()) {
|
| switch (result->type()) {
|
| case CALLBACKS: {
|
| @@ -281,8 +299,8 @@
|
|
|
| // No accessible property found.
|
| *attributes = ABSENT;
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| - return Heap::undefined_value();
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -291,6 +309,7 @@
|
| LookupResult* result,
|
| String* name,
|
| bool continue_search) {
|
| + Heap* heap = name->GetHeap();
|
| if (result->IsProperty()) {
|
| switch (result->type()) {
|
| case CALLBACKS: {
|
| @@ -344,7 +363,7 @@
|
| }
|
| }
|
|
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return ABSENT;
|
| }
|
|
|
| @@ -378,16 +397,14 @@
|
| Object* value,
|
| PropertyDetails details) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = name->GetHeap();
|
| int entry = property_dictionary()->FindEntry(name);
|
| if (entry == StringDictionary::kNotFound) {
|
| Object* store_value = value;
|
| if (IsGlobalObject()) {
|
| - { MaybeObject* maybe_store_value =
|
| - Heap::AllocateJSGlobalPropertyCell(value);
|
| - if (!maybe_store_value->ToObject(&store_value)) {
|
| - return maybe_store_value;
|
| - }
|
| - }
|
| + MaybeObject* maybe_store_value =
|
| + heap->AllocateJSGlobalPropertyCell(value);
|
| + if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
|
| }
|
| Object* dict;
|
| { MaybeObject* maybe_dict =
|
| @@ -416,6 +433,7 @@
|
|
|
| MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| StringDictionary* dictionary = property_dictionary();
|
| int entry = dictionary->FindEntry(name);
|
| if (entry != StringDictionary::kNotFound) {
|
| @@ -423,7 +441,7 @@
|
| if (IsGlobalObject()) {
|
| PropertyDetails details = dictionary->DetailsAt(entry);
|
| if (details.IsDontDelete()) {
|
| - if (mode != FORCE_DELETION) return Heap::false_value();
|
| + if (mode != FORCE_DELETION) return heap->false_value();
|
| // When forced to delete global properties, we have to make a
|
| // map change to invalidate any ICs that think they can load
|
| // from the DontDelete cell without checking if it contains
|
| @@ -436,13 +454,13 @@
|
| }
|
| JSGlobalPropertyCell* cell =
|
| JSGlobalPropertyCell::cast(dictionary->ValueAt(entry));
|
| - cell->set_value(Heap::the_hole_value());
|
| + cell->set_value(heap->the_hole_value());
|
| dictionary->DetailsAtPut(entry, details.AsDeleted());
|
| } else {
|
| return dictionary->DeleteProperty(entry, mode);
|
| }
|
| }
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| @@ -468,6 +486,7 @@
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| + Heap* heap = name->GetHeap();
|
|
|
| // Traverse the prototype chain from the current object (this) to
|
| // the holder and check for access rights. This avoid traversing the
|
| @@ -475,7 +494,7 @@
|
| // holder will always be the interceptor holder and the search may
|
| // only continue with a current object just after the interceptor
|
| // holder in the prototype chain.
|
| - Object* last = result->IsProperty() ? result->holder() : Heap::null_value();
|
| + Object* last = result->IsProperty() ? result->holder() : heap->null_value();
|
| for (Object* current = this; true; current = current->GetPrototype()) {
|
| if (current->IsAccessCheckNeeded()) {
|
| // Check if we're allowed to read from the current object. Note
|
| @@ -483,7 +502,7 @@
|
| // property from the current object, we still check that we have
|
| // access to it.
|
| JSObject* checked = JSObject::cast(current);
|
| - if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) {
|
| + if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
|
| return checked->GetPropertyWithFailedAccessCheck(receiver,
|
| result,
|
| name,
|
| @@ -498,7 +517,7 @@
|
|
|
| if (!result->IsProperty()) {
|
| *attributes = ABSENT;
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| *attributes = result->GetAttributes();
|
| Object* value;
|
| @@ -507,11 +526,11 @@
|
| case NORMAL:
|
| value = holder->GetNormalizedProperty(result);
|
| ASSERT(!value->IsTheHole() || result->IsReadOnly());
|
| - return value->IsTheHole() ? Heap::undefined_value() : value;
|
| + return value->IsTheHole() ? heap->undefined_value() : value;
|
| case FIELD:
|
| value = holder->FastPropertyAt(result->GetFieldIndex());
|
| ASSERT(!value->IsTheHole() || result->IsReadOnly());
|
| - return value->IsTheHole() ? Heap::undefined_value() : value;
|
| + return value->IsTheHole() ? heap->undefined_value() : value;
|
| case CONSTANT_FUNCTION:
|
| return result->GetConstantFunction();
|
| case CALLBACKS:
|
| @@ -536,7 +555,7 @@
|
| }
|
|
|
| Object* holder = NULL;
|
| - Context* global_context = Top::context()->global_context();
|
| + Context* global_context = Isolate::Current()->context()->global_context();
|
| if (IsString()) {
|
| holder = global_context->string_function()->instance_prototype();
|
| } else if (IsNumber()) {
|
| @@ -546,7 +565,7 @@
|
| } else {
|
| // Undefined and null have no indexed properties.
|
| ASSERT(IsUndefined() || IsNull());
|
| - return Heap::undefined_value();
|
| + return HEAP->undefined_value();
|
| }
|
|
|
| return JSObject::cast(holder)->GetElementWithReceiver(receiver, index);
|
| @@ -556,14 +575,15 @@
|
| Object* Object::GetPrototype() {
|
| // The object is either a number, a string, a boolean, or a real JS object.
|
| if (IsJSObject()) return JSObject::cast(this)->map()->prototype();
|
| - Context* context = Top::context()->global_context();
|
| + Heap* heap = Isolate::Current()->heap();
|
| + Context* context = heap->isolate()->context()->global_context();
|
|
|
| if (IsNumber()) return context->number_function()->instance_prototype();
|
| if (IsString()) return context->string_function()->instance_prototype();
|
| if (IsBoolean()) {
|
| return context->boolean_function()->instance_prototype();
|
| } else {
|
| - return Heap::null_value();
|
| + return heap->null_value();
|
| }
|
| }
|
|
|
| @@ -637,9 +657,10 @@
|
| // allowed. This is to avoid an assertion failure when allocating.
|
| // Flattening strings is the only case where we always allow
|
| // allocation because no GC is performed if the allocation fails.
|
| - if (!Heap::IsAllocationAllowed()) return this;
|
| + if (!HEAP->IsAllocationAllowed()) return this;
|
| #endif
|
|
|
| + Heap* heap = GetHeap();
|
| switch (StringShape(this).representation_tag()) {
|
| case kConsStringTag: {
|
| ConsString* cs = ConsString::cast(this);
|
| @@ -649,12 +670,12 @@
|
| // There's little point in putting the flat string in new space if the
|
| // cons string is in old space. It can never get GCed until there is
|
| // an old space GC.
|
| - PretenureFlag tenure = Heap::InNewSpace(this) ? pretenure : TENURED;
|
| + PretenureFlag tenure = heap->InNewSpace(this) ? pretenure : TENURED;
|
| int len = length();
|
| Object* object;
|
| String* result;
|
| if (IsAsciiRepresentation()) {
|
| - { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(len, tenure);
|
| + { MaybeObject* maybe_object = heap->AllocateRawAsciiString(len, tenure);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| result = String::cast(object);
|
| @@ -669,7 +690,7 @@
|
| len - first_length);
|
| } else {
|
| { MaybeObject* maybe_object =
|
| - Heap::AllocateRawTwoByteString(len, tenure);
|
| + heap->AllocateRawTwoByteString(len, tenure);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| result = String::cast(object);
|
| @@ -684,7 +705,7 @@
|
| len - first_length);
|
| }
|
| cs->set_first(result);
|
| - cs->set_second(Heap::empty_string());
|
| + cs->set_second(heap->empty_string());
|
| return result;
|
| }
|
| default:
|
| @@ -708,7 +729,7 @@
|
| resource->length() * sizeof(smart_chars[0])) == 0);
|
| }
|
| #endif // DEBUG
|
| -
|
| + Heap* heap = GetHeap();
|
| int size = this->Size(); // Byte size of the original string.
|
| if (size < ExternalString::kSize) {
|
| // The string is too small to fit an external String in its place. This can
|
| @@ -724,8 +745,8 @@
|
| // Morph the object to an external string by adjusting the map and
|
| // reinitializing the fields.
|
| this->set_map(is_ascii ?
|
| - Heap::external_string_with_ascii_data_map() :
|
| - Heap::external_string_map());
|
| + heap->external_string_with_ascii_data_map() :
|
| + heap->external_string_map());
|
| ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
|
| self->set_length(length);
|
| self->set_hash_field(hash_field);
|
| @@ -736,13 +757,13 @@
|
| self->Hash(); // Force regeneration of the hash value.
|
| // Now morph this external string into a external symbol.
|
| this->set_map(is_ascii ?
|
| - Heap::external_symbol_with_ascii_data_map() :
|
| - Heap::external_symbol_map());
|
| + heap->external_symbol_with_ascii_data_map() :
|
| + heap->external_symbol_map());
|
| }
|
|
|
| // Fill the remainder of the string with dead wood.
|
| int new_size = this->Size(); // Byte size of the external String object.
|
| - Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| + heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| return true;
|
| }
|
|
|
| @@ -759,7 +780,7 @@
|
| resource->length() * sizeof(smart_chars[0])) == 0);
|
| }
|
| #endif // DEBUG
|
| -
|
| + Heap* heap = GetHeap();
|
| int size = this->Size(); // Byte size of the original string.
|
| if (size < ExternalString::kSize) {
|
| // The string is too small to fit an external String in its place. This can
|
| @@ -773,7 +794,7 @@
|
|
|
| // Morph the object to an external string by adjusting the map and
|
| // reinitializing the fields.
|
| - this->set_map(Heap::external_ascii_string_map());
|
| + this->set_map(heap->external_ascii_string_map());
|
| ExternalAsciiString* self = ExternalAsciiString::cast(this);
|
| self->set_length(length);
|
| self->set_hash_field(hash_field);
|
| @@ -783,12 +804,12 @@
|
| if (is_symbol) {
|
| self->Hash(); // Force regeneration of the hash value.
|
| // Now morph this external string into a external symbol.
|
| - this->set_map(Heap::external_ascii_symbol_map());
|
| + this->set_map(heap->external_ascii_symbol_map());
|
| }
|
|
|
| // Fill the remainder of the string with dead wood.
|
| int new_size = this->Size(); // Byte size of the external String object.
|
| - Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| + heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
|
| return true;
|
| }
|
|
|
| @@ -887,15 +908,16 @@
|
| // All other JSObjects are rather similar to each other (JSObject,
|
| // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue).
|
| default: {
|
| + Heap* heap = GetHeap();
|
| Object* constructor = map()->constructor();
|
| bool printed = false;
|
| if (constructor->IsHeapObject() &&
|
| - !Heap::Contains(HeapObject::cast(constructor))) {
|
| + !heap->Contains(HeapObject::cast(constructor))) {
|
| accumulator->Add("!!!INVALID CONSTRUCTOR!!!");
|
| } else {
|
| bool global_object = IsJSGlobalProxy();
|
| if (constructor->IsJSFunction()) {
|
| - if (!Heap::Contains(JSFunction::cast(constructor)->shared())) {
|
| + if (!heap->Contains(JSFunction::cast(constructor)->shared())) {
|
| accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!");
|
| } else {
|
| Object* constructor_name =
|
| @@ -930,12 +952,13 @@
|
|
|
|
|
| void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
|
| - // if (!Heap::InNewSpace(this)) PrintF("*", this);
|
| - if (!Heap::Contains(this)) {
|
| + // if (!HEAP->InNewSpace(this)) PrintF("*", this);
|
| + Heap* heap = GetHeap();
|
| + if (!heap->Contains(this)) {
|
| accumulator->Add("!!!INVALID POINTER!!!");
|
| return;
|
| }
|
| - if (!Heap::Contains(map())) {
|
| + if (!heap->Contains(map())) {
|
| accumulator->Add("!!!INVALID MAP!!!");
|
| return;
|
| }
|
| @@ -1150,14 +1173,14 @@
|
| if (u.bits.exp == 2047) {
|
| // Detect NaN for IEEE double precision floating point.
|
| if ((u.bits.man_low | u.bits.man_high) != 0)
|
| - return Heap::false_value();
|
| + return GetHeap()->false_value();
|
| }
|
| if (u.bits.exp == 0) {
|
| // Detect +0, and -0 for IEEE double precision floating point.
|
| if ((u.bits.man_low | u.bits.man_high) == 0)
|
| - return Heap::false_value();
|
| + return GetHeap()->false_value();
|
| }
|
| - return Heap::true_value();
|
| + return GetHeap()->true_value();
|
| }
|
|
|
|
|
| @@ -1181,14 +1204,14 @@
|
|
|
| String* JSObject::class_name() {
|
| if (IsJSFunction()) {
|
| - return Heap::function_class_symbol();
|
| + return GetHeap()->function_class_symbol();
|
| }
|
| if (map()->constructor()->IsJSFunction()) {
|
| JSFunction* constructor = JSFunction::cast(map()->constructor());
|
| return String::cast(constructor->shared()->instance_class_name());
|
| }
|
| // If the constructor is not present, return "Object".
|
| - return Heap::Object_symbol();
|
| + return GetHeap()->Object_symbol();
|
| }
|
|
|
|
|
| @@ -1203,7 +1226,7 @@
|
| if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name();
|
| }
|
| // If the constructor is not present, return "Object".
|
| - return Heap::Object_symbol();
|
| + return GetHeap()->Object_symbol();
|
| }
|
|
|
|
|
| @@ -1233,9 +1256,10 @@
|
|
|
| // Normalize the object if the name is an actual string (not the
|
| // hidden symbols) and is not a real identifier.
|
| + Isolate* isolate = GetHeap()->isolate();
|
| StringInputBuffer buffer(name);
|
| - if (!ScannerConstants::IsIdentifier(&buffer)
|
| - && name != Heap::hidden_symbol()) {
|
| + if (!isolate->scanner_constants()->IsIdentifier(&buffer)
|
| + && name != HEAP->hidden_symbol()) {
|
| Object* obj;
|
| { MaybeObject* maybe_obj =
|
| NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
|
| @@ -1262,7 +1286,8 @@
|
| // global object_function's map and there is not a transition for name.
|
| bool allow_map_transition =
|
| !old_descriptors->Contains(name) &&
|
| - (Top::context()->global_context()->object_function()->map() != map());
|
| + (isolate->context()->global_context()->object_function()->
|
| + map() != map());
|
|
|
| ASSERT(index < map()->inobject_properties() ||
|
| (index - map()->inobject_properties()) < properties()->length() ||
|
| @@ -1316,7 +1341,8 @@
|
| String* name,
|
| JSFunction* function,
|
| PropertyAttributes attributes) {
|
| - ASSERT(!Heap::InNewSpace(function));
|
| + Heap* heap = GetHeap();
|
| + ASSERT(!heap->InNewSpace(function));
|
|
|
| // Allocate new instance descriptors with (name, function) added
|
| ConstantFunctionDescriptor d(name, function, attributes);
|
| @@ -1341,7 +1367,8 @@
|
|
|
| // If the old map is the global object map (from new Object()),
|
| // then transitions are not added to it, so we are done.
|
| - if (old_map == Top::context()->global_context()->object_function()->map()) {
|
| + if (old_map == heap->isolate()->context()->global_context()->
|
| + object_function()->map()) {
|
| return function;
|
| }
|
|
|
| @@ -1376,6 +1403,7 @@
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| StringDictionary* dict = property_dictionary();
|
| Object* store_value = value;
|
| if (IsGlobalObject()) {
|
| @@ -1393,7 +1421,7 @@
|
| return value;
|
| }
|
| { MaybeObject* maybe_store_value =
|
| - Heap::AllocateJSGlobalPropertyCell(value);
|
| + heap->AllocateJSGlobalPropertyCell(value);
|
| if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
|
| }
|
| JSGlobalPropertyCell::cast(store_value)->set_value(value);
|
| @@ -1412,16 +1440,17 @@
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| ASSERT(!IsJSGlobalProxy());
|
| + Heap* heap = GetHeap();
|
| if (!map()->is_extensible()) {
|
| Handle<Object> args[1] = {Handle<String>(name)};
|
| - return Top::Throw(*Factory::NewTypeError("object_not_extensible",
|
| - HandleVector(args, 1)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewTypeError("object_not_extensible", HandleVector(args, 1)));
|
| }
|
| if (HasFastProperties()) {
|
| // Ensure the descriptor array does not get too big.
|
| if (map()->instance_descriptors()->number_of_descriptors() <
|
| DescriptorArray::kMaxNumberOfDescriptors) {
|
| - if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
|
| + if (value->IsJSFunction() && !heap->InNewSpace(value)) {
|
| return AddConstantFunctionProperty(name,
|
| JSFunction::cast(value),
|
| attributes);
|
| @@ -1493,7 +1522,8 @@
|
| return result;
|
| }
|
| // Do not add transitions to the map of "new Object()".
|
| - if (map() == Top::context()->global_context()->object_function()->map()) {
|
| + if (map() == GetHeap()->isolate()->context()->global_context()->
|
| + object_function()->map()) {
|
| return result;
|
| }
|
|
|
| @@ -1580,29 +1610,31 @@
|
| Object* value,
|
| PropertyAttributes attributes,
|
| StrictModeFlag strict_mode) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> this_handle(this);
|
| Handle<String> name_handle(name);
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| if (!interceptor->setter()->IsUndefined()) {
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate, ApiNamedPropertyAccess("interceptor-named-set", this, name));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::NamedPropertySetter setter =
|
| v8::ToCData<v8::NamedPropertySetter>(interceptor->setter());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| Handle<Object> value_unhole(value->IsTheHole() ?
|
| - Heap::undefined_value() :
|
| - value);
|
| + isolate->heap()->undefined_value() :
|
| + value,
|
| + isolate);
|
| result = setter(v8::Utils::ToLocal(name_handle),
|
| v8::Utils::ToLocal(value_unhole),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *value_handle;
|
| }
|
| MaybeObject* raw_result =
|
| @@ -1610,7 +1642,7 @@
|
| *value_handle,
|
| attributes,
|
| strict_mode);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
| @@ -1629,12 +1661,13 @@
|
| String* name,
|
| Object* value,
|
| JSObject* holder) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
|
|
| // We should never get here to initialize a const with the hole
|
| // value since a const declaration would conflict with the setter.
|
| ASSERT(!value->IsTheHole());
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
|
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| @@ -1643,7 +1676,7 @@
|
| AccessorDescriptor* callback =
|
| reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
|
| MaybeObject* obj = (callback->setter)(this, value, callback->data);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (obj->IsFailure()) return obj;
|
| return *value_handle;
|
| }
|
| @@ -1655,17 +1688,17 @@
|
| v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
|
| if (call_fun == NULL) return value;
|
| Handle<String> key(name);
|
| - LOG(ApiNamedPropertyAccess("store", this, name));
|
| - CustomArguments args(data->data(), this, JSObject::cast(holder));
|
| + LOG(isolate, ApiNamedPropertyAccess("store", this, name));
|
| + CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
|
| v8::AccessorInfo info(args.end());
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| call_fun(v8::Utils::ToLocal(key),
|
| v8::Utils::ToLocal(value_handle),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return *value_handle;
|
| }
|
|
|
| @@ -1675,10 +1708,11 @@
|
| return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
|
| } else {
|
| Handle<String> key(name);
|
| - Handle<Object> holder_handle(holder);
|
| + Handle<Object> holder_handle(holder, isolate);
|
| Handle<Object> args[2] = { key, holder_handle };
|
| - return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("no_setter_in_callback",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
|
|
| @@ -1689,13 +1723,15 @@
|
|
|
| MaybeObject* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
|
| Object* value) {
|
| - Handle<Object> value_handle(value);
|
| - Handle<JSFunction> fun(JSFunction::cast(setter));
|
| - Handle<JSObject> self(this);
|
| + Isolate* isolate = GetIsolate();
|
| + Handle<Object> value_handle(value, isolate);
|
| + Handle<JSFunction> fun(JSFunction::cast(setter), isolate);
|
| + Handle<JSObject> self(this, isolate);
|
| #ifdef ENABLE_DEBUGGER_SUPPORT
|
| + Debug* debug = isolate->debug();
|
| // Handle stepping into a setter if step into is active.
|
| - if (Debug::StepInActive()) {
|
| - Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| + if (debug->StepInActive()) {
|
| + debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
|
| }
|
| #endif
|
| bool has_pending_exception;
|
| @@ -1709,8 +1745,9 @@
|
|
|
| void JSObject::LookupCallbackSetterInPrototypes(String* name,
|
| LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = pt->GetPrototype()) {
|
| JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty()) {
|
| @@ -1730,8 +1767,9 @@
|
| MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
|
| Object* value,
|
| bool* found) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = pt->GetPrototype()) {
|
| if (!JSObject::cast(pt)->HasDictionaryElements()) {
|
| continue;
|
| @@ -1748,7 +1786,7 @@
|
| }
|
| }
|
| *found = false;
|
| - return Heap::the_hole_value();
|
| + return heap->the_hole_value();
|
| }
|
|
|
|
|
| @@ -1767,10 +1805,11 @@
|
| String* name,
|
| LookupResult* result) {
|
| DescriptorArray* descriptors = instance_descriptors();
|
| - int number = DescriptorLookupCache::Lookup(descriptors, name);
|
| + DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache();
|
| + int number = cache->Lookup(descriptors, name);
|
| if (number == DescriptorLookupCache::kAbsent) {
|
| number = descriptors->Search(name);
|
| - DescriptorLookupCache::Update(descriptors, name, number);
|
| + cache->Update(descriptors, name, number);
|
| }
|
| if (number != DescriptorArray::kNotFound) {
|
| result->DescriptorResult(holder, descriptors->GetDetails(number), number);
|
| @@ -1838,8 +1877,9 @@
|
|
|
| void JSObject::LookupRealNamedPropertyInPrototypes(String* name,
|
| LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* pt = GetPrototype();
|
| - pt != Heap::null_value();
|
| + pt != heap->null_value();
|
| pt = JSObject::cast(pt)->GetPrototype()) {
|
| JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty() && (result->type() != INTERCEPTOR)) return;
|
| @@ -1853,6 +1893,7 @@
|
| String* name,
|
| Object* value,
|
| bool check_prototype) {
|
| + Heap* heap = GetHeap();
|
| if (check_prototype && !result->IsProperty()) {
|
| LookupCallbackSetterInPrototypes(name, result);
|
| }
|
| @@ -1893,7 +1934,7 @@
|
|
|
| HandleScope scope;
|
| Handle<Object> value_handle(value);
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| return *value_handle;
|
| }
|
|
|
| @@ -1903,6 +1944,7 @@
|
| Object* value,
|
| PropertyAttributes attributes,
|
| StrictModeFlag strict_mode) {
|
| + Heap* heap = GetHeap();
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -1912,7 +1954,7 @@
|
| // reallocating them.
|
| if (!name->IsSymbol() && name->length() <= 2) {
|
| Object* symbol_version;
|
| - { MaybeObject* maybe_symbol_version = Heap::LookupSymbol(name);
|
| + { MaybeObject* maybe_symbol_version = heap->LookupSymbol(name);
|
| if (maybe_symbol_version->ToObject(&symbol_version)) {
|
| name = String::cast(symbol_version);
|
| }
|
| @@ -1921,7 +1963,7 @@
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded()
|
| - && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| return SetPropertyWithFailedAccessCheck(result, name, value, true);
|
| }
|
|
|
| @@ -1955,8 +1997,8 @@
|
| Handle<String> key(name);
|
| Handle<Object> holder(this);
|
| Handle<Object> args[2] = { key, holder };
|
| - return Top::Throw(*Factory::NewTypeError("strict_read_only_property",
|
| - HandleVector(args, 2)));
|
| + return heap->isolate()->Throw(*heap->isolate()->factory()->NewTypeError(
|
| + "strict_read_only_property", HandleVector(args, 2)));
|
| } else {
|
| return value;
|
| }
|
| @@ -1999,7 +2041,7 @@
|
| ASSERT(target_descriptors->GetType(number) == CONSTANT_FUNCTION);
|
| JSFunction* function =
|
| JSFunction::cast(target_descriptors->GetValue(number));
|
| - ASSERT(!Heap::InNewSpace(function));
|
| + ASSERT(!HEAP->InNewSpace(function));
|
| if (value == function) {
|
| set_map(target_map);
|
| return value;
|
| @@ -2028,6 +2070,8 @@
|
| String* name,
|
| Object* value,
|
| PropertyAttributes attributes) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -2035,7 +2079,7 @@
|
| LocalLookup(name, &result);
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded()
|
| - && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| return SetPropertyWithFailedAccessCheck(&result, name, value, false);
|
| }
|
|
|
| @@ -2107,7 +2151,7 @@
|
| if (continue_search) {
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| - if (pt != Heap::null_value()) {
|
| + if (!pt->IsNull()) {
|
| return JSObject::cast(pt)->
|
| GetPropertyAttributeWithReceiver(receiver, name);
|
| }
|
| @@ -2120,25 +2164,28 @@
|
| JSObject* receiver,
|
| String* name,
|
| bool continue_search) {
|
| + Isolate* isolate = GetIsolate();
|
| +
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
|
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| Handle<String> name_handle(name);
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| if (!interceptor->query()->IsUndefined()) {
|
| v8::NamedPropertyQuery query =
|
| v8::ToCData<v8::NamedPropertyQuery>(interceptor->query());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
|
| v8::Handle<v8::Integer> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = query(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| if (!result.IsEmpty()) {
|
| @@ -2148,11 +2195,12 @@
|
| } else if (!interceptor->getter()->IsUndefined()) {
|
| v8::NamedPropertyGetter getter =
|
| v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| if (!result.IsEmpty()) return DONT_ENUM;
|
| @@ -2182,9 +2230,10 @@
|
| LookupResult* result,
|
| String* name,
|
| bool continue_search) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| + !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| return GetPropertyAttributeWithFailedAccessCheck(receiver,
|
| result,
|
| name,
|
| @@ -2250,7 +2299,7 @@
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| set(index, result);
|
| - Counters::normalized_maps.Increment();
|
| + COUNTERS->normalized_maps()->Increment();
|
|
|
| return result;
|
| }
|
| @@ -2310,7 +2359,7 @@
|
| UNIQUE_NORMALIZED_MAP);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| - Counters::normalized_maps.Increment();
|
| + COUNTERS->normalized_maps()->Increment();
|
|
|
| set_map(Map::cast(obj));
|
| }
|
| @@ -2324,10 +2373,11 @@
|
|
|
| // The global object is always normalized.
|
| ASSERT(!IsGlobalObject());
|
| -
|
| // JSGlobalProxy must never be normalized
|
| ASSERT(!IsJSGlobalProxy());
|
|
|
| + Heap* heap = GetHeap();
|
| +
|
| // Allocate new content.
|
| int property_count = map()->NumberOfDescribedProperties();
|
| if (expected_additional_properties > 0) {
|
| @@ -2396,8 +2446,8 @@
|
| int index = map()->instance_descriptors()->NextEnumerationIndex();
|
| dictionary->SetNextEnumerationIndex(index);
|
|
|
| - { MaybeObject* maybe_obj = Top::context()->global_context()->
|
| - normalized_map_cache()->Get(this, mode);
|
| + { MaybeObject* maybe_obj = heap->isolate()->context()->global_context()->
|
| + normalized_map_cache()->Get(this, mode);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| Map* new_map = Map::cast(obj);
|
| @@ -2409,14 +2459,15 @@
|
| int new_instance_size = new_map->instance_size();
|
| int instance_size_delta = map()->instance_size() - new_instance_size;
|
| ASSERT(instance_size_delta >= 0);
|
| - Heap::CreateFillerObjectAt(this->address() + new_instance_size,
|
| + heap->CreateFillerObjectAt(this->address() + new_instance_size,
|
| instance_size_delta);
|
|
|
| set_map(new_map);
|
| + map()->set_instance_descriptors(heap->empty_descriptor_array());
|
|
|
| set_properties(dictionary);
|
|
|
| - Counters::props_to_dictionary.Increment();
|
| + heap->isolate()->counters()->props_to_dictionary()->Increment();
|
|
|
| #ifdef DEBUG
|
| if (FLAG_trace_normalization) {
|
| @@ -2477,7 +2528,8 @@
|
| set_map(new_map);
|
| set_elements(dictionary);
|
|
|
| - Counters::elements_to_dictionary.Increment();
|
| + new_map->GetHeap()->isolate()->counters()->elements_to_dictionary()->
|
| + Increment();
|
|
|
| #ifdef DEBUG
|
| if (FLAG_trace_normalization) {
|
| @@ -2493,9 +2545,10 @@
|
| MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name,
|
| DeleteMode mode) {
|
| // Check local property, ignore interceptor.
|
| + Heap* heap = GetHeap();
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| - if (!result.IsProperty()) return Heap::true_value();
|
| + if (!result.IsProperty()) return heap->true_value();
|
|
|
| // Normalize object if needed.
|
| Object* obj;
|
| @@ -2508,23 +2561,25 @@
|
|
|
|
|
| MaybeObject* JSObject::DeletePropertyWithInterceptor(String* name) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
|
| Handle<String> name_handle(name);
|
| Handle<JSObject> this_handle(this);
|
| if (!interceptor->deleter()->IsUndefined()) {
|
| v8::NamedPropertyDeleter deleter =
|
| v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Boolean> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = deleter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| ASSERT(result->IsBoolean());
|
| return *v8::Utils::OpenHandle(*result);
|
| @@ -2532,13 +2587,14 @@
|
| }
|
| MaybeObject* raw_result =
|
| this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index,
|
| DeleteMode mode) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!HasExternalArrayElements());
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS: {
|
| @@ -2566,52 +2622,56 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| + Heap* heap = isolate->heap();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| - if (interceptor->deleter()->IsUndefined()) return Heap::false_value();
|
| + if (interceptor->deleter()->IsUndefined()) return heap->false_value();
|
| v8::IndexedPropertyDeleter deleter =
|
| v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter());
|
| Handle<JSObject> this_handle(this);
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Boolean> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = deleter(index, info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| ASSERT(result->IsBoolean());
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
| MaybeObject* raw_result =
|
| this_handle->DeleteElementPostInterceptor(index, NORMAL_DELETION);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
|
| + Isolate* isolate = GetIsolate();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| - return Heap::false_value();
|
| + !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| - if (proto->IsNull()) return Heap::false_value();
|
| + if (proto->IsNull()) return isolate->heap()->false_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
|
| }
|
| @@ -2654,15 +2714,16 @@
|
| int entry = dictionary->FindEntry(index);
|
| if (entry != NumberDictionary::kNotFound) {
|
| Object* result = dictionary->DeleteProperty(entry, mode);
|
| - if (mode == STRICT_DELETION && result == Heap::false_value()) {
|
| + if (mode == STRICT_DELETION && result ==
|
| + isolate->heap()->false_value()) {
|
| // In strict mode, deleting a non-configurable property throws
|
| // exception. dictionary->DeleteProperty will return false_value()
|
| // if a non-configurable property is being deleted.
|
| HandleScope scope;
|
| - Handle<Object> i = Factory::NewNumberFromUint(index);
|
| + Handle<Object> i = isolate->factory()->NewNumberFromUint(index);
|
| Handle<Object> args[2] = { i, Handle<Object>(this) };
|
| - return Top::Throw(*Factory::NewTypeError("strict_delete_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(*isolate->factory()->NewTypeError(
|
| + "strict_delete_property", HandleVector(args, 2)));
|
| }
|
| }
|
| break;
|
| @@ -2671,24 +2732,25 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::true_value();
|
| + return isolate->heap()->true_value();
|
| }
|
|
|
|
|
| MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
|
| + Isolate* isolate = GetIsolate();
|
| // ECMA-262, 3rd, 8.6.2.5
|
| ASSERT(name->IsString());
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| - return Heap::false_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| - if (proto->IsNull()) return Heap::false_value();
|
| + if (proto->IsNull()) return isolate->heap()->false_value();
|
| ASSERT(proto->IsJSGlobalObject());
|
| return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
|
| }
|
| @@ -2699,17 +2761,17 @@
|
| } else {
|
| LookupResult result;
|
| LocalLookup(name, &result);
|
| - if (!result.IsProperty()) return Heap::true_value();
|
| + if (!result.IsProperty()) return isolate->heap()->true_value();
|
| // Ignore attributes if forcing a deletion.
|
| if (result.IsDontDelete() && mode != FORCE_DELETION) {
|
| if (mode == STRICT_DELETION) {
|
| // Deleting a non-configurable property in strict mode.
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) };
|
| - return Top::Throw(*Factory::NewTypeError("strict_delete_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(*isolate->factory()->NewTypeError(
|
| + "strict_delete_property", HandleVector(args, 2)));
|
| }
|
| - return Heap::false_value();
|
| + return isolate->heap()->false_value();
|
| }
|
| // Check for interceptor.
|
| if (result.type() == INTERCEPTOR) {
|
| @@ -2733,6 +2795,7 @@
|
|
|
| // Check whether this object references another object.
|
| bool JSObject::ReferencesObject(Object* obj) {
|
| + Heap* heap = GetHeap();
|
| AssertNoAllocation no_alloc;
|
|
|
| // Is the object the constructor for this object?
|
| @@ -2747,7 +2810,7 @@
|
|
|
| // Check if the object is among the named properties.
|
| Object* key = SlowReverseLookup(obj);
|
| - if (key != Heap::undefined_value()) {
|
| + if (!key->IsUndefined()) {
|
| return true;
|
| }
|
|
|
| @@ -2778,7 +2841,7 @@
|
| }
|
| case DICTIONARY_ELEMENTS: {
|
| key = element_dictionary()->SlowReverseLookup(obj);
|
| - if (key != Heap::undefined_value()) {
|
| + if (!key->IsUndefined()) {
|
| return true;
|
| }
|
| break;
|
| @@ -2792,7 +2855,8 @@
|
| if (IsJSFunction()) {
|
| // Get the constructor function for arguments array.
|
| JSObject* arguments_boilerplate =
|
| - Top::context()->global_context()->arguments_boilerplate();
|
| + heap->isolate()->context()->global_context()->
|
| + arguments_boilerplate();
|
| JSFunction* arguments_function =
|
| JSFunction::cast(arguments_boilerplate->map()->constructor());
|
|
|
| @@ -2831,10 +2895,13 @@
|
|
|
|
|
| MaybeObject* JSObject::PreventExtensions() {
|
| + Isolate* isolate = GetIsolate();
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, Heap::undefined_value(), v8::ACCESS_KEYS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
|
| - return Heap::false_value();
|
| + !isolate->MayNamedAccess(this,
|
| + isolate->heap()->undefined_value(),
|
| + v8::ACCESS_KEYS)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
|
| + return isolate->heap()->false_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -2873,8 +2940,9 @@
|
| // - This object has no elements.
|
| // - No prototype has enumerable properties/elements.
|
| bool JSObject::IsSimpleEnum() {
|
| + Heap* heap = GetHeap();
|
| for (Object* o = this;
|
| - o != Heap::null_value();
|
| + o != heap->null_value();
|
| o = JSObject::cast(o)->GetPrototype()) {
|
| JSObject* curr = JSObject::cast(o);
|
| if (!curr->map()->instance_descriptors()->HasEnumCache()) return false;
|
| @@ -2940,6 +3008,8 @@
|
| void JSObject::LocalLookup(String* name, LookupResult* result) {
|
| ASSERT(name->IsString());
|
|
|
| + Heap* heap = GetHeap();
|
| +
|
| if (IsJSGlobalProxy()) {
|
| Object* proto = GetPrototype();
|
| if (proto->IsNull()) return result->NotFound();
|
| @@ -2954,13 +3024,14 @@
|
| }
|
|
|
| // Check __proto__ before interceptor.
|
| - if (name->Equals(Heap::Proto_symbol()) && !IsJSContextExtensionObject()) {
|
| + if (name->Equals(heap->Proto_symbol()) &&
|
| + !IsJSContextExtensionObject()) {
|
| result->ConstantResult(this);
|
| return;
|
| }
|
|
|
| // Check for lookup interceptor except when bootstrapping.
|
| - if (HasNamedInterceptor() && !Bootstrapper::IsActive()) {
|
| + if (HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive()) {
|
| result->InterceptorResult(this);
|
| return;
|
| }
|
| @@ -2971,8 +3042,9 @@
|
|
|
| void JSObject::Lookup(String* name, LookupResult* result) {
|
| // Ecma-262 3rd 8.6.2.4
|
| + Heap* heap = GetHeap();
|
| for (Object* current = this;
|
| - current != Heap::null_value();
|
| + current != heap->null_value();
|
| current = JSObject::cast(current)->GetPrototype()) {
|
| JSObject::cast(current)->LocalLookup(name, result);
|
| if (result->IsProperty()) return;
|
| @@ -2983,8 +3055,9 @@
|
|
|
| // Search object and it's prototype chain for callback properties.
|
| void JSObject::LookupCallback(String* name, LookupResult* result) {
|
| + Heap* heap = GetHeap();
|
| for (Object* current = this;
|
| - current != Heap::null_value();
|
| + current != heap->null_value();
|
| current = JSObject::cast(current)->GetPrototype()) {
|
| JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
|
| if (result->IsProperty() && result->type() == CALLBACKS) return;
|
| @@ -2995,6 +3068,7 @@
|
|
|
| MaybeObject* JSObject::DefineGetterSetter(String* name,
|
| PropertyAttributes attributes) {
|
| + Heap* heap = GetHeap();
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
| @@ -3003,7 +3077,7 @@
|
| name->TryFlatten();
|
|
|
| if (!CanSetCallback(name)) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
| uint32_t index = 0;
|
| @@ -3023,7 +3097,7 @@
|
| case EXTERNAL_FLOAT_ELEMENTS:
|
| // Ignore getters and setters on pixel and external array
|
| // elements.
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| case DICTIONARY_ELEMENTS: {
|
| // Lookup the index.
|
| NumberDictionary* dictionary = element_dictionary();
|
| @@ -3031,7 +3105,7 @@
|
| if (entry != NumberDictionary::kNotFound) {
|
| Object* result = dictionary->ValueAt(entry);
|
| PropertyDetails details = dictionary->DetailsAt(entry);
|
| - if (details.IsReadOnly()) return Heap::undefined_value();
|
| + if (details.IsReadOnly()) return heap->undefined_value();
|
| if (details.type() == CALLBACKS) {
|
| if (result->IsFixedArray()) {
|
| return result;
|
| @@ -3050,7 +3124,7 @@
|
| LookupResult result;
|
| LocalLookup(name, &result);
|
| if (result.IsProperty()) {
|
| - if (result.IsReadOnly()) return Heap::undefined_value();
|
| + if (result.IsReadOnly()) return heap->undefined_value();
|
| if (result.type() == CALLBACKS) {
|
| Object* obj = result.GetCallbackObject();
|
| // Need to preserve old getters/setters.
|
| @@ -3064,7 +3138,7 @@
|
|
|
| // Allocate the fixed array to hold getter and setter.
|
| Object* structure;
|
| - { MaybeObject* maybe_structure = Heap::AllocateFixedArray(2, TENURED);
|
| + { MaybeObject* maybe_structure = heap->AllocateFixedArray(2, TENURED);
|
| if (!maybe_structure->ToObject(&structure)) return maybe_structure;
|
| }
|
|
|
| @@ -3078,7 +3152,7 @@
|
|
|
| bool JSObject::CanSetCallback(String* name) {
|
| ASSERT(!IsAccessCheckNeeded()
|
| - || Top::MayNamedAccess(this, name, v8::ACCESS_SET));
|
| + || Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET));
|
|
|
| // Check if there is an API defined callback object which prohibits
|
| // callback overwriting in this object or it's prototype chain.
|
| @@ -3175,11 +3249,12 @@
|
| Object* fun,
|
| PropertyAttributes attributes) {
|
| ASSERT(fun->IsJSFunction() || fun->IsUndefined());
|
| + Isolate* isolate = GetIsolate();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| - return Heap::undefined_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -3201,12 +3276,13 @@
|
|
|
|
|
| MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
|
| + Isolate* isolate = GetIsolate();
|
| String* name = String::cast(info->name());
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| - return Heap::undefined_value();
|
| + !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
|
| + isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| if (IsJSGlobalProxy()) {
|
| @@ -3224,14 +3300,14 @@
|
| name->TryFlatten();
|
|
|
| if (!CanSetCallback(name)) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| uint32_t index = 0;
|
| bool is_element = name->AsArrayIndex(&index);
|
|
|
| if (is_element) {
|
| - if (IsJSArray()) return Heap::undefined_value();
|
| + if (IsJSArray()) return isolate->heap()->undefined_value();
|
|
|
| // Accessors overwrite previous callbacks (cf. with getters/setters).
|
| switch (GetElementsKind()) {
|
| @@ -3247,7 +3323,7 @@
|
| case EXTERNAL_FLOAT_ELEMENTS:
|
| // Ignore getters and setters on pixel and external array
|
| // elements.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| case DICTIONARY_ELEMENTS:
|
| break;
|
| default:
|
| @@ -3267,7 +3343,7 @@
|
| // ES5 forbids turning a property into an accessor if it's not
|
| // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
|
| if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) {
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
| Object* ok;
|
| { MaybeObject* maybe_ok =
|
| @@ -3281,15 +3357,17 @@
|
|
|
|
|
| Object* JSObject::LookupAccessor(String* name, bool is_getter) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Make sure that the top context does not change when doing callbacks or
|
| // interceptor calls.
|
| AssertNoContextChange ncc;
|
|
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| - return Heap::undefined_value();
|
| + !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + return heap->undefined_value();
|
| }
|
|
|
| // Make the lookup and include prototypes.
|
| @@ -3297,7 +3375,7 @@
|
| uint32_t index = 0;
|
| if (name->AsArrayIndex(&index)) {
|
| for (Object* obj = this;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = JSObject::cast(obj)->GetPrototype()) {
|
| JSObject* js_object = JSObject::cast(obj);
|
| if (js_object->HasDictionaryElements()) {
|
| @@ -3316,12 +3394,12 @@
|
| }
|
| } else {
|
| for (Object* obj = this;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = JSObject::cast(obj)->GetPrototype()) {
|
| LookupResult result;
|
| JSObject::cast(obj)->LocalLookup(name, &result);
|
| if (result.IsProperty()) {
|
| - if (result.IsReadOnly()) return Heap::undefined_value();
|
| + if (result.IsReadOnly()) return heap->undefined_value();
|
| if (result.type() == CALLBACKS) {
|
| Object* obj = result.GetCallbackObject();
|
| if (obj->IsFixedArray()) {
|
| @@ -3331,11 +3409,12 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| Object* JSObject::SlowReverseLookup(Object* value) {
|
| + Heap* heap = GetHeap();
|
| if (HasFastProperties()) {
|
| DescriptorArray* descs = map()->instance_descriptors();
|
| for (int i = 0; i < descs->number_of_descriptors(); i++) {
|
| @@ -3349,7 +3428,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| } else {
|
| return property_dictionary()->SlowReverseLookup(value);
|
| }
|
| @@ -3357,9 +3436,10 @@
|
|
|
|
|
| MaybeObject* Map::CopyDropDescriptors() {
|
| + Heap* heap = GetHeap();
|
| Object* result;
|
| { MaybeObject* maybe_result =
|
| - Heap::AllocateMap(instance_type(), instance_size());
|
| + heap->AllocateMap(instance_type(), instance_size());
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| Map::cast(result)->set_prototype(prototype());
|
| @@ -3369,7 +3449,8 @@
|
| // pointing to the same transition which is bad because the garbage
|
| // collector relies on being able to reverse pointers from transitions
|
| // to maps. If properties need to be retained use CopyDropTransitions.
|
| - Map::cast(result)->set_instance_descriptors(Heap::empty_descriptor_array());
|
| + Map::cast(result)->set_instance_descriptors(
|
| + heap->empty_descriptor_array());
|
| // Please note instance_type and instance_size are set when allocated.
|
| Map::cast(result)->set_inobject_properties(inobject_properties());
|
| Map::cast(result)->set_unused_property_fields(unused_property_fields());
|
| @@ -3392,7 +3473,7 @@
|
| Map::cast(result)->set_bit_field(bit_field());
|
| Map::cast(result)->set_bit_field2(bit_field2());
|
| Map::cast(result)->set_is_shared(false);
|
| - Map::cast(result)->ClearCodeCache();
|
| + Map::cast(result)->ClearCodeCache(heap);
|
| return result;
|
| }
|
|
|
| @@ -3406,7 +3487,7 @@
|
|
|
| Object* result;
|
| { MaybeObject* maybe_result =
|
| - Heap::AllocateMap(instance_type(), new_instance_size);
|
| + GetHeap()->AllocateMap(instance_type(), new_instance_size);
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
|
|
| @@ -3451,7 +3532,7 @@
|
| // Allocate the code cache if not present.
|
| if (code_cache()->IsFixedArray()) {
|
| Object* result;
|
| - { MaybeObject* maybe_result = Heap::AllocateCodeCache();
|
| + { MaybeObject* maybe_result = GetHeap()->AllocateCodeCache();
|
| if (!maybe_result->ToObject(&result)) return maybe_result;
|
| }
|
| set_code_cache(result);
|
| @@ -3467,7 +3548,7 @@
|
| if (!code_cache()->IsFixedArray()) {
|
| return CodeCache::cast(code_cache())->Lookup(name, flags);
|
| } else {
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
| }
|
|
|
| @@ -3491,12 +3572,13 @@
|
|
|
| void Map::TraverseTransitionTree(TraverseCallback callback, void* data) {
|
| Map* current = this;
|
| - while (current != Heap::meta_map()) {
|
| + Map* meta_map = heap()->meta_map();
|
| + while (current != meta_map) {
|
| DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
|
| *RawField(current, Map::kInstanceDescriptorsOffset));
|
| - if (d == Heap::empty_descriptor_array()) {
|
| + if (d == heap()->empty_descriptor_array()) {
|
| Map* prev = current->map();
|
| - current->set_map(Heap::meta_map());
|
| + current->set_map(meta_map);
|
| callback(current, data);
|
| current = prev;
|
| continue;
|
| @@ -3521,9 +3603,9 @@
|
| }
|
| }
|
| if (!map_done) continue;
|
| - *map_or_index_field = Heap::fixed_array_map();
|
| + *map_or_index_field = heap()->fixed_array_map();
|
| Map* prev = current->map();
|
| - current->set_map(Heap::meta_map());
|
| + current->set_map(meta_map);
|
| callback(current, data);
|
| current = prev;
|
| }
|
| @@ -3636,6 +3718,7 @@
|
|
|
|
|
| Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) {
|
| + Heap* heap = GetHeap();
|
| FixedArray* cache = default_cache();
|
| int length = cache->length();
|
| for (int i = 0; i < length; i += kCodeCacheEntrySize) {
|
| @@ -3650,7 +3733,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -3659,7 +3742,7 @@
|
| CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
|
| return cache->Lookup(name, flags);
|
| } else {
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
| }
|
|
|
| @@ -3741,7 +3824,7 @@
|
| MUST_USE_RESULT MaybeObject* AsObject() {
|
| ASSERT(code_ != NULL);
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(2);
|
| + { MaybeObject* maybe_obj = code_->GetHeap()->AllocateFixedArray(2);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* pair = FixedArray::cast(obj);
|
| @@ -3760,7 +3843,7 @@
|
| Object* CodeCacheHashTable::Lookup(String* name, Code::Flags flags) {
|
| CodeCacheHashTableKey key(name, flags);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return GetHeap()->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -3797,8 +3880,9 @@
|
|
|
| void CodeCacheHashTable::RemoveByIndex(int index) {
|
| ASSERT(index >= 0);
|
| - set(EntryToIndex(index), Heap::null_value());
|
| - set(EntryToIndex(index) + 1, Heap::null_value());
|
| + Heap* heap = GetHeap();
|
| + set(EntryToIndex(index), heap->null_value());
|
| + set(EntryToIndex(index) + 1, heap->null_value());
|
| ElementRemoved();
|
| }
|
|
|
| @@ -3818,6 +3902,7 @@
|
|
|
|
|
| MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!array->HasExternalArrayElements());
|
| switch (array->GetElementsKind()) {
|
| case JSObject::FAST_ELEMENTS:
|
| @@ -3828,7 +3913,7 @@
|
|
|
| // Allocate a temporary fixed array.
|
| Object* object;
|
| - { MaybeObject* maybe_object = Heap::AllocateFixedArray(size);
|
| + { MaybeObject* maybe_object = heap->AllocateFixedArray(size);
|
| if (!maybe_object->ToObject(&object)) return maybe_object;
|
| }
|
| FixedArray* key_array = FixedArray::cast(object);
|
| @@ -3848,11 +3933,12 @@
|
| UNREACHABLE();
|
| }
|
| UNREACHABLE();
|
| - return Heap::null_value(); // Failure case needs to "return" a value.
|
| + return heap->null_value(); // Failure case needs to "return" a value.
|
| }
|
|
|
|
|
| MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
|
| + Heap* heap = GetHeap();
|
| int len0 = length();
|
| #ifdef DEBUG
|
| if (FLAG_enable_slow_asserts) {
|
| @@ -3878,7 +3964,7 @@
|
|
|
| // Allocate the result
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(len0 + extra);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(len0 + extra);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| // Fill in the content
|
| @@ -3907,9 +3993,10 @@
|
|
|
|
|
| MaybeObject* FixedArray::CopySize(int new_length) {
|
| - if (new_length == 0) return Heap::empty_fixed_array();
|
| + Heap* heap = GetHeap();
|
| + if (new_length == 0) return heap->empty_fixed_array();
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(new_length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* result = FixedArray::cast(obj);
|
| @@ -3947,13 +4034,14 @@
|
|
|
|
|
| MaybeObject* DescriptorArray::Allocate(int number_of_descriptors) {
|
| + Heap* heap = Isolate::Current()->heap();
|
| if (number_of_descriptors == 0) {
|
| - return Heap::empty_descriptor_array();
|
| + return heap->empty_descriptor_array();
|
| }
|
| // Allocate the array of keys.
|
| Object* array;
|
| { MaybeObject* maybe_array =
|
| - Heap::AllocateFixedArray(ToKeyIndex(number_of_descriptors));
|
| + heap->AllocateFixedArray(ToKeyIndex(number_of_descriptors));
|
| if (!maybe_array->ToObject(&array)) return maybe_array;
|
| }
|
| // Do not use DescriptorArray::cast on incomplete object.
|
| @@ -3961,7 +4049,7 @@
|
|
|
| // Allocate the content array and set it in the descriptor array.
|
| { MaybeObject* maybe_array =
|
| - Heap::AllocateFixedArray(number_of_descriptors << 1);
|
| + heap->AllocateFixedArray(number_of_descriptors << 1);
|
| if (!maybe_array->ToObject(&array)) return maybe_array;
|
| }
|
| result->set(kContentArrayIndex, array);
|
| @@ -4230,15 +4318,15 @@
|
| MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
|
| PretenureFlag pretenure) {
|
| ASSERT(deopt_entry_count > 0);
|
| - return Heap::AllocateFixedArray(LengthFor(deopt_entry_count),
|
| + return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count),
|
| pretenure);
|
| }
|
|
|
|
|
| MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points,
|
| PretenureFlag pretenure) {
|
| - if (number_of_deopt_points == 0) return Heap::empty_fixed_array();
|
| - return Heap::AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
|
| + if (number_of_deopt_points == 0) return HEAP->empty_fixed_array();
|
| + return HEAP->AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
|
| pretenure);
|
| }
|
|
|
| @@ -4256,11 +4344,8 @@
|
| #endif
|
|
|
|
|
| -static StaticResource<StringInputBuffer> string_input_buffer;
|
| -
|
| -
|
| bool String::LooksValid() {
|
| - if (!Heap::Contains(this)) return false;
|
| + if (!Isolate::Current()->heap()->Contains(this)) return false;
|
| return true;
|
| }
|
|
|
| @@ -4271,8 +4356,10 @@
|
| // doesn't make Utf8Length faster, but it is very likely that
|
| // the string will be accessed later (for example by WriteUtf8)
|
| // so it's still a good idea.
|
| + Heap* heap = GetHeap();
|
| TryFlatten();
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(0, this);
|
| int result = 0;
|
| while (buffer->has_more())
|
| @@ -4342,12 +4429,14 @@
|
| if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
|
| return SmartPointer<char>(NULL);
|
| }
|
| + Heap* heap = GetHeap();
|
|
|
| // Negative length means the to the end of the string.
|
| if (length < 0) length = kMaxInt - offset;
|
|
|
| // Compute the size of the UTF-8 string. Start at the specified offset.
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(offset, this);
|
| int character_position = offset;
|
| int utf8_bytes = 0;
|
| @@ -4417,12 +4506,13 @@
|
|
|
| SmartPointer<uc16> String::ToWideCString(RobustnessFlag robust_flag) {
|
| ASSERT(NativeAllocationChecker::allocation_allowed());
|
| -
|
| if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
|
| return SmartPointer<uc16>();
|
| }
|
| + Heap* heap = GetHeap();
|
|
|
| - Access<StringInputBuffer> buffer(&string_input_buffer);
|
| + Access<StringInputBuffer> buffer(
|
| + heap->isolate()->objects_string_input_buffer());
|
| buffer->Reset(this);
|
|
|
| uc16* result = NewArray<uc16>(length() + 1);
|
| @@ -4705,11 +4795,9 @@
|
| }
|
|
|
|
|
| -Relocatable* Relocatable::top_ = NULL;
|
| -
|
| -
|
| void Relocatable::PostGarbageCollectionProcessing() {
|
| - Relocatable* current = top_;
|
| + Isolate* isolate = Isolate::Current();
|
| + Relocatable* current = isolate->relocatable_top();
|
| while (current != NULL) {
|
| current->PostGarbageCollection();
|
| current = current->prev_;
|
| @@ -4719,21 +4807,23 @@
|
|
|
| // Reserve space for statics needing saving and restoring.
|
| int Relocatable::ArchiveSpacePerThread() {
|
| - return sizeof(top_);
|
| + return sizeof(Isolate::Current()->relocatable_top());
|
| }
|
|
|
|
|
| // Archive statics that are thread local.
|
| char* Relocatable::ArchiveState(char* to) {
|
| - *reinterpret_cast<Relocatable**>(to) = top_;
|
| - top_ = NULL;
|
| + Isolate* isolate = Isolate::Current();
|
| + *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top();
|
| + isolate->set_relocatable_top(NULL);
|
| return to + ArchiveSpacePerThread();
|
| }
|
|
|
|
|
| // Restore statics that are thread local.
|
| char* Relocatable::RestoreState(char* from) {
|
| - top_ = *reinterpret_cast<Relocatable**>(from);
|
| + Isolate* isolate = Isolate::Current();
|
| + isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
|
| return from + ArchiveSpacePerThread();
|
| }
|
|
|
| @@ -4746,7 +4836,8 @@
|
|
|
|
|
| void Relocatable::Iterate(ObjectVisitor* v) {
|
| - Iterate(v, top_);
|
| + Isolate* isolate = Isolate::Current();
|
| + Iterate(v, isolate->relocatable_top());
|
| }
|
|
|
|
|
| @@ -4759,15 +4850,17 @@
|
| }
|
|
|
|
|
| -FlatStringReader::FlatStringReader(Handle<String> str)
|
| - : str_(str.location()),
|
| +FlatStringReader::FlatStringReader(Isolate* isolate, Handle<String> str)
|
| + : Relocatable(isolate),
|
| + str_(str.location()),
|
| length_(str->length()) {
|
| PostGarbageCollection();
|
| }
|
|
|
|
|
| -FlatStringReader::FlatStringReader(Vector<const char> input)
|
| - : str_(0),
|
| +FlatStringReader::FlatStringReader(Isolate* isolate, Vector<const char> input)
|
| + : Relocatable(isolate),
|
| + str_(0),
|
| is_ascii_(true),
|
| length_(input.length()),
|
| start_(input.start()) { }
|
| @@ -5097,11 +5190,10 @@
|
| }
|
|
|
|
|
| -static StringInputBuffer string_compare_buffer_b;
|
| -
|
| -
|
| template <typename IteratorA>
|
| -static inline bool CompareStringContentsPartial(IteratorA* ia, String* b) {
|
| +static inline bool CompareStringContentsPartial(Isolate* isolate,
|
| + IteratorA* ia,
|
| + String* b) {
|
| if (b->IsFlat()) {
|
| if (b->IsAsciiRepresentation()) {
|
| VectorIterator<char> ib(b->ToAsciiVector());
|
| @@ -5111,16 +5203,16 @@
|
| return CompareStringContents(ia, &ib);
|
| }
|
| } else {
|
| - string_compare_buffer_b.Reset(0, b);
|
| - return CompareStringContents(ia, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, b);
|
| + return CompareStringContents(ia,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| }
|
|
|
|
|
| -static StringInputBuffer string_compare_buffer_a;
|
| +bool String::SlowEquals(String* other) {
|
| + Heap* heap = GetHeap();
|
|
|
| -
|
| -bool String::SlowEquals(String* other) {
|
| // Fast check: negative check with lengths.
|
| int len = length();
|
| if (len != other->length()) return false;
|
| @@ -5147,6 +5239,7 @@
|
| Vector<const char>(str2, len));
|
| }
|
|
|
| + Isolate* isolate = heap->isolate();
|
| if (lhs->IsFlat()) {
|
| if (lhs->IsAsciiRepresentation()) {
|
| Vector<const char> vec1 = lhs->ToAsciiVector();
|
| @@ -5161,8 +5254,9 @@
|
| }
|
| } else {
|
| VectorIterator<char> buf1(vec1);
|
| - string_compare_buffer_b.Reset(0, rhs);
|
| - return CompareStringContents(&buf1, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
|
| + return CompareStringContents(&buf1,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| } else {
|
| Vector<const uc16> vec1 = lhs->ToUC16Vector();
|
| @@ -5177,13 +5271,15 @@
|
| }
|
| } else {
|
| VectorIterator<uc16> buf1(vec1);
|
| - string_compare_buffer_b.Reset(0, rhs);
|
| - return CompareStringContents(&buf1, &string_compare_buffer_b);
|
| + isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
|
| + return CompareStringContents(&buf1,
|
| + isolate->objects_string_compare_buffer_b());
|
| }
|
| }
|
| } else {
|
| - string_compare_buffer_a.Reset(0, lhs);
|
| - return CompareStringContentsPartial(&string_compare_buffer_a, rhs);
|
| + isolate->objects_string_compare_buffer_a()->Reset(0, lhs);
|
| + return CompareStringContentsPartial(isolate,
|
| + isolate->objects_string_compare_buffer_a(), rhs);
|
| }
|
| }
|
|
|
| @@ -5192,11 +5288,12 @@
|
| if (StringShape(this).IsSymbol()) return false;
|
|
|
| Map* map = this->map();
|
| - if (map == Heap::string_map()) {
|
| - this->set_map(Heap::undetectable_string_map());
|
| + Heap* heap = map->GetHeap();
|
| + if (map == heap->string_map()) {
|
| + this->set_map(heap->undetectable_string_map());
|
| return true;
|
| - } else if (map == Heap::ascii_string_map()) {
|
| - this->set_map(Heap::undetectable_ascii_string_map());
|
| + } else if (map == heap->ascii_string_map()) {
|
| + this->set_map(heap->undetectable_ascii_string_map());
|
| return true;
|
| }
|
| // Rest cannot be marked as undetectable
|
| @@ -5205,9 +5302,10 @@
|
|
|
|
|
| bool String::IsEqualTo(Vector<const char> str) {
|
| + Isolate* isolate = GetIsolate();
|
| int slen = length();
|
| Access<ScannerConstants::Utf8Decoder>
|
| - decoder(ScannerConstants::utf8_decoder());
|
| + decoder(isolate->scanner_constants()->utf8_decoder());
|
| decoder->Reset(str.start(), str.length());
|
| int i;
|
| for (i = 0; i < slen && decoder->has_more(); i++) {
|
| @@ -5369,8 +5467,9 @@
|
|
|
|
|
| MaybeObject* String::SubString(int start, int end, PretenureFlag pretenure) {
|
| + Heap* heap = GetHeap();
|
| if (start == 0 && end == length()) return this;
|
| - MaybeObject* result = Heap::AllocateSubString(this, start, end, pretenure);
|
| + MaybeObject* result = heap->AllocateSubString(this, start, end, pretenure);
|
| return result;
|
| }
|
|
|
| @@ -5410,12 +5509,12 @@
|
| }
|
|
|
|
|
| -void Map::ClearNonLiveTransitions(Object* real_prototype) {
|
| +void Map::ClearNonLiveTransitions(Heap* heap, Object* real_prototype) {
|
| // Live DescriptorArray objects will be marked, so we must use
|
| // low-level accessors to get and modify their data.
|
| DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
|
| *RawField(this, Map::kInstanceDescriptorsOffset));
|
| - if (d == Heap::raw_unchecked_empty_descriptor_array()) return;
|
| + if (d == heap->raw_unchecked_empty_descriptor_array()) return;
|
| Smi* NullDescriptorDetails =
|
| PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi();
|
| FixedArray* contents = reinterpret_cast<FixedArray*>(
|
| @@ -5435,7 +5534,7 @@
|
| if (!target->IsMarked()) {
|
| ASSERT(target->IsMap());
|
| contents->set_unchecked(i + 1, NullDescriptorDetails);
|
| - contents->set_null_unchecked(i);
|
| + contents->set_null_unchecked(heap, i);
|
| ASSERT(target->prototype() == this ||
|
| target->prototype() == real_prototype);
|
| // Getter prototype() is read-only, set_prototype() has side effects.
|
| @@ -5459,7 +5558,8 @@
|
| ASSERT(is_compiled() && !IsOptimized());
|
| ASSERT(shared()->allows_lazy_compilation() ||
|
| code()->optimizable());
|
| - ReplaceCode(Builtins::builtin(Builtins::LazyRecompile));
|
| + Builtins* builtins = GetIsolate()->builtins();
|
| + ReplaceCode(builtins->builtin(Builtins::LazyRecompile));
|
| }
|
|
|
|
|
| @@ -5492,7 +5592,7 @@
|
|
|
| Object* JSFunction::SetInstancePrototype(Object* value) {
|
| ASSERT(value->IsJSObject());
|
| -
|
| + Heap* heap = GetHeap();
|
| if (has_initial_map()) {
|
| initial_map()->set_prototype(value);
|
| } else {
|
| @@ -5501,7 +5601,7 @@
|
| // prototype is put into the initial map where it belongs.
|
| set_prototype_or_initial_map(value);
|
| }
|
| - Heap::ClearInstanceofCache();
|
| + heap->ClearInstanceofCache();
|
| return value;
|
| }
|
|
|
| @@ -5515,6 +5615,7 @@
|
| // used for constructing objects to the original object prototype.
|
| // See ECMA-262 13.2.2.
|
| if (!value->IsJSObject()) {
|
| + Heap* heap = GetHeap();
|
| // Copy the map so this does not affect unrelated functions.
|
| // Remove map transitions because they point to maps with a
|
| // different prototype.
|
| @@ -5526,7 +5627,8 @@
|
| map()->set_constructor(value);
|
| map()->set_non_instance_prototype(true);
|
| construct_prototype =
|
| - Top::context()->global_context()->initial_object_prototype();
|
| + heap->isolate()->context()->global_context()->
|
| + initial_object_prototype();
|
| } else {
|
| map()->set_non_instance_prototype(false);
|
| }
|
| @@ -5551,7 +5653,7 @@
|
| ASSERT(shared()->strict_mode() || map() == global_context->function_map());
|
|
|
| set_map(no_prototype_map);
|
| - set_prototype_or_initial_map(Heap::the_hole_value());
|
| + set_prototype_or_initial_map(GetHeap()->the_hole_value());
|
| return this;
|
| }
|
|
|
| @@ -5573,13 +5675,17 @@
|
| }
|
|
|
|
|
| -MaybeObject* Oddball::Initialize(const char* to_string, Object* to_number) {
|
| +MaybeObject* Oddball::Initialize(const char* to_string,
|
| + Object* to_number,
|
| + byte kind) {
|
| Object* symbol;
|
| - { MaybeObject* maybe_symbol = Heap::LookupAsciiSymbol(to_string);
|
| + { MaybeObject* maybe_symbol =
|
| + Isolate::Current()->heap()->LookupAsciiSymbol(to_string);
|
| if (!maybe_symbol->ToObject(&symbol)) return maybe_symbol;
|
| }
|
| set_to_string(String::cast(symbol));
|
| set_to_number(to_number);
|
| + set_kind(kind);
|
| return this;
|
| }
|
|
|
| @@ -5598,10 +5704,11 @@
|
|
|
|
|
| Object* SharedFunctionInfo::GetSourceCode() {
|
| - if (!HasSourceCode()) return Heap::undefined_value();
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + if (!HasSourceCode()) return isolate->heap()->undefined_value();
|
| + HandleScope scope(isolate);
|
| Object* source = Script::cast(script())->source();
|
| - return *SubString(Handle<String>(String::cast(source)),
|
| + return *SubString(Handle<String>(String::cast(source), isolate),
|
| start_position(), end_position());
|
| }
|
|
|
| @@ -5628,6 +5735,8 @@
|
|
|
|
|
| bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check the basic conditions for generating inline constructor code.
|
| if (!FLAG_inline_new
|
| || !has_only_simple_this_property_assignments()
|
| @@ -5644,7 +5753,7 @@
|
| // Traverse the proposed prototype chain looking for setters for properties of
|
| // the same names as are set by the inline constructor.
|
| for (Object* obj = prototype;
|
| - obj != Heap::null_value();
|
| + obj != heap->null_value();
|
| obj = obj->GetPrototype()) {
|
| JSObject* js_object = JSObject::cast(obj);
|
| for (int i = 0; i < this_property_assignments_count(); i++) {
|
| @@ -5680,10 +5789,11 @@
|
|
|
|
|
| void SharedFunctionInfo::ClearThisPropertyAssignmentsInfo() {
|
| + Heap* heap = GetHeap();
|
| set_compiler_hints(BooleanBit::set(compiler_hints(),
|
| kHasOnlySimpleThisPropertyAssignments,
|
| false));
|
| - set_this_property_assignments(Heap::undefined_value());
|
| + set_this_property_assignments(heap->undefined_value());
|
| set_this_property_assignments_count(0);
|
| }
|
|
|
| @@ -5828,9 +5938,10 @@
|
| set_construction_count(kGenerousAllocationCount);
|
| }
|
| set_initial_map(map);
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric),
|
| construct_stub());
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown));
|
| }
|
|
|
|
|
| @@ -5847,10 +5958,11 @@
|
| // then StartInobjectTracking will be called again the next time the
|
| // constructor is called. The countdown will continue and (possibly after
|
| // several more GCs) CompleteInobjectSlackTracking will eventually be called.
|
| - set_initial_map(Heap::raw_unchecked_undefined_value());
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
|
| + set_initial_map(map->heap()->raw_unchecked_undefined_value());
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown),
|
| *RawField(this, kConstructStubOffset));
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric));
|
| // It is safe to clear the flag: it will be set again if the map is live.
|
| set_live_objects_may_exist(false);
|
| }
|
| @@ -5863,9 +5975,10 @@
|
|
|
| // Resume inobject slack tracking.
|
| set_initial_map(map);
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
|
| + Builtins* builtins = map->heap()->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubGeneric),
|
| *RawField(this, kConstructStubOffset));
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubCountdown));
|
| // The map survived the gc, so there may be objects referencing it.
|
| set_live_objects_may_exist(true);
|
| }
|
| @@ -5894,10 +6007,12 @@
|
| ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress());
|
| Map* map = Map::cast(initial_map());
|
|
|
| - set_initial_map(Heap::undefined_value());
|
| - ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
|
| + Heap* heap = map->heap();
|
| + set_initial_map(heap->undefined_value());
|
| + Builtins* builtins = heap->isolate()->builtins();
|
| + ASSERT_EQ(builtins->builtin(Builtins::JSConstructStubCountdown),
|
| construct_stub());
|
| - set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
|
| + set_construct_stub(builtins->builtin(Builtins::JSConstructStubGeneric));
|
|
|
| int slack = map->unused_property_fields();
|
| map->TraverseTransitionTree(&GetMinInobjectSlack, &slack);
|
| @@ -5954,8 +6069,7 @@
|
|
|
|
|
| void Code::InvalidateRelocation() {
|
| - HandleScope scope;
|
| - set_relocation_info(Heap::empty_byte_array());
|
| + set_relocation_info(GetHeap()->empty_byte_array());
|
| }
|
|
|
|
|
| @@ -6401,11 +6515,12 @@
|
|
|
| MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
|
| int length) {
|
| + Heap* heap = GetHeap();
|
| // We should never end in here with a pixel or external array.
|
| ASSERT(!HasExternalArrayElements());
|
|
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* elems = FixedArray::cast(obj);
|
| @@ -6492,14 +6607,15 @@
|
|
|
|
|
| MaybeObject* JSArray::Initialize(int capacity) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(capacity >= 0);
|
| set_length(Smi::FromInt(0));
|
| FixedArray* new_elements;
|
| if (capacity == 0) {
|
| - new_elements = Heap::empty_fixed_array();
|
| + new_elements = heap->empty_fixed_array();
|
| } else {
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| new_elements = FixedArray::cast(obj);
|
| @@ -6514,21 +6630,23 @@
|
| Handle<FixedArray> old_backing(FixedArray::cast(elements()));
|
| int old_size = old_backing->length();
|
| int new_size = required_size > old_size ? required_size : old_size;
|
| - Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
|
| + Handle<FixedArray> new_backing = FACTORY->NewFixedArray(new_size);
|
| // Can't use this any more now because we may have had a GC!
|
| for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
|
| self->SetContent(*new_backing);
|
| }
|
|
|
|
|
| -static Failure* ArrayLengthRangeError() {
|
| +static Failure* ArrayLengthRangeError(Heap* heap) {
|
| HandleScope scope;
|
| - return Top::Throw(*Factory::NewRangeError("invalid_array_length",
|
| - HandleVector<Object>(NULL, 0)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewRangeError("invalid_array_length",
|
| + HandleVector<Object>(NULL, 0)));
|
| }
|
|
|
|
|
| MaybeObject* JSObject::SetElementsLength(Object* len) {
|
| + Heap* heap = GetHeap();
|
| // We should never end in here with a pixel or external array.
|
| ASSERT(AllowsSetElementsLength());
|
|
|
| @@ -6536,7 +6654,7 @@
|
| Object* smi_length = Smi::FromInt(0);
|
| if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) {
|
| const int value = Smi::cast(smi_length)->value();
|
| - if (value < 0) return ArrayLengthRangeError();
|
| + if (value < 0) return ArrayLengthRangeError(heap);
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS: {
|
| int old_capacity = FixedArray::cast(elements())->length();
|
| @@ -6602,14 +6720,14 @@
|
| if (len->ToArrayIndex(&length)) {
|
| return SetSlowElements(len);
|
| } else {
|
| - return ArrayLengthRangeError();
|
| + return ArrayLengthRangeError(heap);
|
| }
|
| }
|
|
|
| // len is not a number so make the array size one and
|
| // set only element to len.
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(1);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(1);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray::cast(obj)->set(0, len);
|
| @@ -6621,6 +6739,7 @@
|
|
|
| MaybeObject* JSObject::SetPrototype(Object* value,
|
| bool skip_hidden_prototypes) {
|
| + Heap* heap = GetHeap();
|
| // Silently ignore the change if value is not a JSObject or null.
|
| // SpiderMonkey behaves this way.
|
| if (!value->IsJSObject() && !value->IsNull()) return value;
|
| @@ -6629,12 +6748,12 @@
|
| // prototype cycles are prevented.
|
| // It is sufficient to validate that the receiver is not in the new prototype
|
| // chain.
|
| - for (Object* pt = value; pt != Heap::null_value(); pt = pt->GetPrototype()) {
|
| + for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
|
| if (JSObject::cast(pt) == this) {
|
| // Cycle detected.
|
| HandleScope scope;
|
| - return Top::Throw(*Factory::NewError("cyclic_proto",
|
| - HandleVector<Object>(NULL, 0)));
|
| + return heap->isolate()->Throw(
|
| + *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
|
| }
|
| }
|
|
|
| @@ -6659,7 +6778,7 @@
|
| Map::cast(new_map)->set_prototype(value);
|
| real_receiver->set_map(Map::cast(new_map));
|
|
|
| - Heap::ClearInstanceofCache();
|
| + heap->ClearInstanceofCache();
|
|
|
| return value;
|
| }
|
| @@ -6714,29 +6833,31 @@
|
| if (this->IsStringObjectWithCharacterAt(index)) return true;
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return false;
|
| + if (pt->IsNull()) return false;
|
| return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
|
| }
|
|
|
|
|
| bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| if (!interceptor->query()->IsUndefined()) {
|
| v8::IndexedPropertyQuery query =
|
| v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
|
| v8::Handle<v8::Integer> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = query(index, info);
|
| }
|
| if (!result.IsEmpty()) {
|
| @@ -6746,11 +6867,12 @@
|
| } else if (!interceptor->getter()->IsUndefined()) {
|
| v8::IndexedPropertyGetter getter =
|
| v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(index, info);
|
| }
|
| if (!result.IsEmpty()) return true;
|
| @@ -6760,10 +6882,12 @@
|
|
|
|
|
| JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return UNDEFINED_ELEMENT;
|
| }
|
|
|
| @@ -6830,10 +6954,12 @@
|
|
|
|
|
| bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| +
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -6888,7 +7014,7 @@
|
| if (this->IsStringObjectWithCharacterAt(index)) return true;
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return false;
|
| + if (pt->IsNull()) return false;
|
| return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
|
| }
|
|
|
| @@ -6897,26 +7023,28 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<JSObject> this_handle(this);
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
| if (!interceptor->setter()->IsUndefined()) {
|
| v8::IndexedPropertySetter setter =
|
| v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
|
| - CustomArguments args(interceptor->data(), this, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), this, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = setter(index, v8::Utils::ToLocal(value_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *value_handle;
|
| }
|
| MaybeObject* raw_result =
|
| @@ -6924,7 +7052,7 @@
|
| *value_handle,
|
| strict_mode,
|
| check_prototype);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
| @@ -6933,6 +7061,7 @@
|
| Object* structure,
|
| uint32_t index,
|
| Object* holder) {
|
| + Isolate* isolate = GetIsolate();
|
| ASSERT(!structure->IsProxy());
|
|
|
| // api style callbacks.
|
| @@ -6940,22 +7069,22 @@
|
| AccessorInfo* data = AccessorInfo::cast(structure);
|
| Object* fun_obj = data->getter();
|
| v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> self(JSObject::cast(receiver));
|
| Handle<JSObject> holder_handle(JSObject::cast(holder));
|
| - Handle<Object> number = Factory::NewNumberFromUint(index);
|
| - Handle<String> key(Factory::NumberToString(number));
|
| - LOG(ApiNamedPropertyAccess("load", *self, *key));
|
| - CustomArguments args(data->data(), *self, *holder_handle);
|
| + Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
| + Handle<String> key(isolate->factory()->NumberToString(number));
|
| + LOG(isolate, ApiNamedPropertyAccess("load", *self, *key));
|
| + CustomArguments args(isolate, data->data(), *self, *holder_handle);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = call_fun(v8::Utils::ToLocal(key), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| - if (result.IsEmpty()) return Heap::undefined_value();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| + if (result.IsEmpty()) return isolate->heap()->undefined_value();
|
| return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| @@ -6967,7 +7096,7 @@
|
| JSFunction::cast(getter));
|
| }
|
| // Getter is not a function.
|
| - return Heap::undefined_value();
|
| + return isolate->heap()->undefined_value();
|
| }
|
|
|
| UNREACHABLE();
|
| @@ -6979,12 +7108,13 @@
|
| uint32_t index,
|
| Object* value,
|
| JSObject* holder) {
|
| - HandleScope scope;
|
| + Isolate* isolate = GetIsolate();
|
| + HandleScope scope(isolate);
|
|
|
| // We should never get here to initialize a const with the hole
|
| // value since a const declaration would conflict with the setter.
|
| ASSERT(!value->IsTheHole());
|
| - Handle<Object> value_handle(value);
|
| + Handle<Object> value_handle(value, isolate);
|
|
|
| // To accommodate both the old and the new api we switch on the
|
| // data structure used to store the callbacks. Eventually proxy
|
| @@ -6997,19 +7127,19 @@
|
| Object* call_obj = data->setter();
|
| v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
|
| if (call_fun == NULL) return value;
|
| - Handle<Object> number = Factory::NewNumberFromUint(index);
|
| - Handle<String> key(Factory::NumberToString(number));
|
| - LOG(ApiNamedPropertyAccess("store", this, *key));
|
| - CustomArguments args(data->data(), this, JSObject::cast(holder));
|
| + Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
|
| + Handle<String> key(isolate->factory()->NumberToString(number));
|
| + LOG(isolate, ApiNamedPropertyAccess("store", this, *key));
|
| + CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
|
| v8::AccessorInfo info(args.end());
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| call_fun(v8::Utils::ToLocal(key),
|
| v8::Utils::ToLocal(value_handle),
|
| info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return *value_handle;
|
| }
|
|
|
| @@ -7018,11 +7148,12 @@
|
| if (setter->IsJSFunction()) {
|
| return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
|
| } else {
|
| - Handle<Object> holder_handle(holder);
|
| - Handle<Object> key(Factory::NewNumberFromUint(index));
|
| + Handle<Object> holder_handle(holder, isolate);
|
| + Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
|
| Handle<Object> args[2] = { key, holder_handle };
|
| - return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("no_setter_in_callback",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
|
|
| @@ -7101,12 +7232,13 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_SET)) {
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
|
| HandleScope scope;
|
| Handle<Object> value_handle(value);
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
|
| return *value_handle;
|
| }
|
|
|
| @@ -7139,6 +7271,7 @@
|
| Object* value,
|
| StrictModeFlag strict_mode,
|
| bool check_prototype) {
|
| + Isolate* isolate = GetIsolate();
|
| switch (GetElementsKind()) {
|
| case FAST_ELEMENTS:
|
| // Fast case.
|
| @@ -7194,12 +7327,12 @@
|
| // If put fails instrict mode, throw exception.
|
| if (!dictionary->ValueAtPut(entry, value) &&
|
| strict_mode == kStrictMode) {
|
| - Handle<Object> number(Factory::NewNumberFromUint(index));
|
| + Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
|
| Handle<Object> holder(this);
|
| Handle<Object> args[2] = { number, holder };
|
| - return Top::Throw(
|
| - *Factory::NewTypeError("strict_read_only_property",
|
| - HandleVector(args, 2)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("strict_read_only_property",
|
| + HandleVector(args, 2)));
|
| }
|
| }
|
| } else {
|
| @@ -7214,11 +7347,13 @@
|
| // When we set the is_extensible flag to false we always force
|
| // the element into dictionary mode (and force them to stay there).
|
| if (!map()->is_extensible()) {
|
| - Handle<Object> number(Factory::NewNumberFromUint(index));
|
| - Handle<String> index_string(Factory::NumberToString(number));
|
| + Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
|
| + Handle<String> index_string(
|
| + isolate->factory()->NumberToString(number));
|
| Handle<Object> args[1] = { index_string };
|
| - return Top::Throw(*Factory::NewTypeError("object_not_extensible",
|
| - HandleVector(args, 1)));
|
| + return isolate->Throw(
|
| + *isolate->factory()->NewTypeError("object_not_extensible",
|
| + HandleVector(args, 1)));
|
| }
|
| Object* result;
|
| { MaybeObject* maybe_result = dictionary->AtNumberPut(index, value);
|
| @@ -7271,7 +7406,7 @@
|
| // All possible cases have been handled above. Add a return to avoid the
|
| // complaints from the compiler.
|
| UNREACHABLE();
|
| - return Heap::null_value();
|
| + return isolate->heap()->null_value();
|
| }
|
|
|
|
|
| @@ -7284,7 +7419,7 @@
|
| if (index >= old_len && index != 0xffffffff) {
|
| Object* len;
|
| { MaybeObject* maybe_len =
|
| - Heap::NumberFromDouble(static_cast<double>(index) + 1);
|
| + GetHeap()->NumberFromDouble(static_cast<double>(index) + 1);
|
| if (!maybe_len->ToObject(&len)) return maybe_len;
|
| }
|
| set_length(len);
|
| @@ -7295,6 +7430,7 @@
|
|
|
| MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver,
|
| uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Get element works for both JSObject and JSArray since
|
| // JSArray::length cannot change.
|
| switch (GetElementsKind()) {
|
| @@ -7343,17 +7479,18 @@
|
|
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt->IsNull()) return heap->undefined_value();
|
| return pt->GetElementWithReceiver(receiver, index);
|
| }
|
|
|
|
|
| MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver,
|
| uint32_t index) {
|
| + Isolate* isolate = GetIsolate();
|
| // Make sure that the top context does not change when doing
|
| // callbacks or interceptor calls.
|
| AssertNoContextChange ncc;
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
|
| Handle<Object> this_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| @@ -7361,33 +7498,35 @@
|
| if (!interceptor->getter()->IsUndefined()) {
|
| v8::IndexedPropertyGetter getter =
|
| v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + LOG(isolate,
|
| + ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(index, info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
|
| }
|
|
|
| MaybeObject* raw_result =
|
| holder_handle->GetElementPostInterceptor(*this_handle, index);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return raw_result;
|
| }
|
|
|
|
|
| MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
|
| uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_GET)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| - return Heap::undefined_value();
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_GET)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
|
| + return heap->undefined_value();
|
| }
|
|
|
| if (HasIndexedInterceptor()) {
|
| @@ -7438,7 +7577,7 @@
|
| }
|
|
|
| Object* pt = GetPrototype();
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt == heap->null_value()) return heap->undefined_value();
|
| return pt->GetElementWithReceiver(receiver, index);
|
| }
|
|
|
| @@ -7493,7 +7632,7 @@
|
| ExternalIntArray* array = ExternalIntArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| int32_t value = array->get(index);
|
| - return Heap::NumberFromInt32(value);
|
| + return GetHeap()->NumberFromInt32(value);
|
| }
|
| break;
|
| }
|
| @@ -7502,7 +7641,7 @@
|
| ExternalUnsignedIntArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| uint32_t value = array->get(index);
|
| - return Heap::NumberFromUint32(value);
|
| + return GetHeap()->NumberFromUint32(value);
|
| }
|
| break;
|
| }
|
| @@ -7510,7 +7649,7 @@
|
| ExternalFloatArray* array = ExternalFloatArray::cast(elements());
|
| if (index < static_cast<uint32_t>(array->length())) {
|
| float value = array->get(index);
|
| - return Heap::AllocateHeapNumber(value);
|
| + return GetHeap()->AllocateHeapNumber(value);
|
| }
|
| break;
|
| }
|
| @@ -7519,7 +7658,7 @@
|
| UNREACHABLE();
|
| break;
|
| }
|
| - return Heap::undefined_value();
|
| + return GetHeap()->undefined_value();
|
| }
|
|
|
|
|
| @@ -7664,6 +7803,7 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = GetHeap();
|
| // Check local property in holder, ignore interceptor.
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| @@ -7673,7 +7813,7 @@
|
| // Continue searching via the prototype chain.
|
| Object* pt = GetPrototype();
|
| *attributes = ABSENT;
|
| - if (pt == Heap::null_value()) return Heap::undefined_value();
|
| + if (pt->IsNull()) return heap->undefined_value();
|
| return pt->GetPropertyWithReceiver(receiver, name, attributes);
|
| }
|
|
|
| @@ -7682,13 +7822,14 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Heap* heap = GetHeap();
|
| // Check local property in holder, ignore interceptor.
|
| LookupResult result;
|
| LocalLookupRealNamedProperty(name, &result);
|
| if (result.IsProperty()) {
|
| return GetProperty(receiver, &result, name, attributes);
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -7696,8 +7837,9 @@
|
| JSObject* receiver,
|
| String* name,
|
| PropertyAttributes* attributes) {
|
| + Isolate* isolate = GetIsolate();
|
| InterceptorInfo* interceptor = GetNamedInterceptor();
|
| - HandleScope scope;
|
| + HandleScope scope(isolate);
|
| Handle<JSObject> receiver_handle(receiver);
|
| Handle<JSObject> holder_handle(this);
|
| Handle<String> name_handle(name);
|
| @@ -7705,16 +7847,17 @@
|
| if (!interceptor->getter()->IsUndefined()) {
|
| v8::NamedPropertyGetter getter =
|
| v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
|
| - LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
|
| - CustomArguments args(interceptor->data(), receiver, this);
|
| + LOG(isolate,
|
| + ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
|
| + CustomArguments args(isolate, interceptor->data(), receiver, this);
|
| v8::AccessorInfo info(args.end());
|
| v8::Handle<v8::Value> result;
|
| {
|
| // Leaving JavaScript.
|
| - VMState state(EXTERNAL);
|
| + VMState state(isolate, EXTERNAL);
|
| result = getter(v8::Utils::ToLocal(name_handle), info);
|
| }
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| if (!result.IsEmpty()) {
|
| *attributes = NONE;
|
| return *v8::Utils::OpenHandle(*result);
|
| @@ -7725,16 +7868,17 @@
|
| *receiver_handle,
|
| *name_handle,
|
| attributes);
|
| - RETURN_IF_SCHEDULED_EXCEPTION();
|
| + RETURN_IF_SCHEDULED_EXCEPTION(isolate);
|
| return result;
|
| }
|
|
|
|
|
| bool JSObject::HasRealNamedProperty(String* key) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -7745,10 +7889,11 @@
|
|
|
|
|
| bool JSObject::HasRealElementProperty(uint32_t index) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -7788,15 +7933,16 @@
|
| }
|
| // All possibilities have been handled above already.
|
| UNREACHABLE();
|
| - return Heap::null_value();
|
| + return heap->null_value();
|
| }
|
|
|
|
|
| bool JSObject::HasRealNamedCallbackProperty(String* key) {
|
| + Heap* heap = GetHeap();
|
| // Check access rights if needed.
|
| if (IsAccessCheckNeeded() &&
|
| - !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| - Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| + !heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
|
| + heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
|
| return false;
|
| }
|
|
|
| @@ -8059,51 +8205,6 @@
|
| }
|
|
|
|
|
| -bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
|
| - ASSERT(other->IsNumber());
|
| - return key == static_cast<uint32_t>(other->Number());
|
| -}
|
| -
|
| -
|
| -uint32_t NumberDictionaryShape::Hash(uint32_t key) {
|
| - return ComputeIntegerHash(key);
|
| -}
|
| -
|
| -
|
| -uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) {
|
| - ASSERT(other->IsNumber());
|
| - return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
|
| -}
|
| -
|
| -
|
| -MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
|
| - return Heap::NumberFromUint32(key);
|
| -}
|
| -
|
| -
|
| -bool StringDictionaryShape::IsMatch(String* key, Object* other) {
|
| - // We know that all entries in a hash table had their hash keys created.
|
| - // Use that knowledge to have fast failure.
|
| - if (key->Hash() != String::cast(other)->Hash()) return false;
|
| - return key->Equals(String::cast(other));
|
| -}
|
| -
|
| -
|
| -uint32_t StringDictionaryShape::Hash(String* key) {
|
| - return key->Hash();
|
| -}
|
| -
|
| -
|
| -uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) {
|
| - return String::cast(other)->Hash();
|
| -}
|
| -
|
| -
|
| -MaybeObject* StringDictionaryShape::AsObject(String* key) {
|
| - return key;
|
| -}
|
| -
|
| -
|
| // StringKey simply carries a string object as key.
|
| class StringKey : public HashTableKey {
|
| public:
|
| @@ -8186,7 +8287,7 @@
|
|
|
| MUST_USE_RESULT MaybeObject* AsObject() {
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(3);
|
| + { MaybeObject* maybe_obj = source_->GetHeap()->AllocateFixedArray(3);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* pair = FixedArray::cast(obj);
|
| @@ -8270,7 +8371,8 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateSymbol(string_, chars_, hash_field_);
|
| + return Isolate::Current()->heap()->AllocateSymbol(
|
| + string_, chars_, hash_field_);
|
| }
|
|
|
| Vector<const char> string_;
|
| @@ -8337,7 +8439,7 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateAsciiSymbol(string_, hash_field_);
|
| + return HEAP->AllocateAsciiSymbol(string_, hash_field_);
|
| }
|
| };
|
|
|
| @@ -8353,7 +8455,7 @@
|
|
|
| MaybeObject* AsObject() {
|
| if (hash_field_ == 0) Hash();
|
| - return Heap::AllocateTwoByteSymbol(string_, hash_field_);
|
| + return HEAP->AllocateTwoByteSymbol(string_, hash_field_);
|
| }
|
| };
|
|
|
| @@ -8361,7 +8463,8 @@
|
| // SymbolKey carries a string/symbol object as key.
|
| class SymbolKey : public HashTableKey {
|
| public:
|
| - explicit SymbolKey(String* string) : string_(string) { }
|
| + explicit SymbolKey(String* string)
|
| + : string_(string) { }
|
|
|
| bool IsMatch(Object* string) {
|
| return String::cast(string)->Equals(string_);
|
| @@ -8377,8 +8480,9 @@
|
| // Attempt to flatten the string, so that symbols will most often
|
| // be flat strings.
|
| string_ = string_->TryFlattenGetString();
|
| + Heap* heap = string_->GetHeap();
|
| // Transform string to symbol if possible.
|
| - Map* map = Heap::SymbolMapForString(string_);
|
| + Map* map = heap->SymbolMapForString(string_);
|
| if (map != NULL) {
|
| string_->set_map(map);
|
| ASSERT(string_->IsSymbol());
|
| @@ -8386,7 +8490,7 @@
|
| }
|
| // Otherwise allocate a new symbol.
|
| StringInputBuffer buffer(string_);
|
| - return Heap::AllocateInternalSymbol(&buffer,
|
| + return heap->AllocateInternalSymbol(&buffer,
|
| string_->length(),
|
| string_->hash_field());
|
| }
|
| @@ -8425,8 +8529,8 @@
|
| }
|
|
|
| Object* obj;
|
| - { MaybeObject* maybe_obj =
|
| - Heap::AllocateHashTable(EntryToIndex(capacity), pretenure);
|
| + { MaybeObject* maybe_obj = Isolate::Current()->heap()->
|
| + AllocateHashTable(EntryToIndex(capacity), pretenure);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| HashTable::cast(obj)->SetNumberOfElements(0);
|
| @@ -8437,23 +8541,6 @@
|
|
|
|
|
| // Find entry for key otherwise return kNotFound.
|
| -template<typename Shape, typename Key>
|
| -int HashTable<Shape, Key>::FindEntry(Key key) {
|
| - uint32_t capacity = Capacity();
|
| - uint32_t entry = FirstProbe(Shape::Hash(key), capacity);
|
| - uint32_t count = 1;
|
| - // EnsureCapacity will guarantee the hash table is never full.
|
| - while (true) {
|
| - Object* element = KeyAt(entry);
|
| - if (element->IsUndefined()) break; // Empty entry.
|
| - if (!element->IsNull() && Shape::IsMatch(key, element)) return entry;
|
| - entry = NextProbe(entry, count++, capacity);
|
| - }
|
| - return kNotFound;
|
| -}
|
| -
|
| -
|
| -// Find entry for key otherwise return kNotFound.
|
| int StringDictionary::FindEntry(String* key) {
|
| if (!key->IsSymbol()) {
|
| return HashTable<StringDictionaryShape, String*>::FindEntry(key);
|
| @@ -8495,6 +8582,7 @@
|
|
|
| template<typename Shape, typename Key>
|
| MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) {
|
| + Heap* heap = GetHeap();
|
| int capacity = Capacity();
|
| int nof = NumberOfElements() + n;
|
| int nod = NumberOfDeletedElements();
|
| @@ -8508,7 +8596,7 @@
|
|
|
| const int kMinCapacityForPretenure = 256;
|
| bool pretenure =
|
| - (capacity > kMinCapacityForPretenure) && !Heap::InNewSpace(this);
|
| + (capacity > kMinCapacityForPretenure) && !heap->InNewSpace(this);
|
| Object* obj;
|
| { MaybeObject* maybe_obj =
|
| Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED);
|
| @@ -8640,6 +8728,7 @@
|
| // Collates undefined and unexisting elements below limit from position
|
| // zero of the elements. The object stays in Dictionary mode.
|
| MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(HasDictionaryElements());
|
| // Must stay in dictionary mode, either because of requires_slow_elements,
|
| // or because we are not going to sort (and therefore compact) all of the
|
| @@ -8649,7 +8738,7 @@
|
| if (limit > static_cast<uint32_t>(Smi::kMaxValue)) {
|
| // Allocate space for result before we start mutating the object.
|
| Object* new_double;
|
| - { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
|
| + { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0);
|
| if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
|
| }
|
| result_double = HeapNumber::cast(new_double);
|
| @@ -8715,7 +8804,7 @@
|
| // allocation. Bailout.
|
| return Smi::FromInt(-1);
|
| }
|
| - new_dict->AddNumberEntry(pos, Heap::undefined_value(), no_details)->
|
| + new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)->
|
| ToObjectUnchecked();
|
| pos++;
|
| undefs--;
|
| @@ -8738,6 +8827,7 @@
|
| // If the object is in dictionary mode, it is converted to fast elements
|
| // mode.
|
| MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
|
| + Heap* heap = GetHeap();
|
| ASSERT(!HasExternalArrayElements());
|
|
|
| if (HasDictionaryElements()) {
|
| @@ -8756,10 +8846,10 @@
|
| }
|
| Map* new_map = Map::cast(obj);
|
|
|
| - PretenureFlag tenure = Heap::InNewSpace(this) ? NOT_TENURED: TENURED;
|
| + PretenureFlag tenure = heap->InNewSpace(this) ? NOT_TENURED: TENURED;
|
| Object* new_array;
|
| { MaybeObject* maybe_new_array =
|
| - Heap::AllocateFixedArray(dict->NumberOfElements(), tenure);
|
| + heap->AllocateFixedArray(dict->NumberOfElements(), tenure);
|
| if (!maybe_new_array->ToObject(&new_array)) return maybe_new_array;
|
| }
|
| FixedArray* fast_elements = FixedArray::cast(new_array);
|
| @@ -8792,7 +8882,7 @@
|
| // Pessimistically allocate space for return value before
|
| // we start mutating the array.
|
| Object* new_double;
|
| - { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
|
| + { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0);
|
| if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
|
| }
|
| result_double = HeapNumber::cast(new_double);
|
| @@ -8886,7 +8976,8 @@
|
|
|
|
|
| template<typename ExternalArrayClass, typename ValueType>
|
| -static MaybeObject* ExternalArrayIntSetter(ExternalArrayClass* receiver,
|
| +static MaybeObject* ExternalArrayIntSetter(Heap* heap,
|
| + ExternalArrayClass* receiver,
|
| uint32_t index,
|
| Object* value) {
|
| ValueType cast_value = 0;
|
| @@ -8904,45 +8995,46 @@
|
| }
|
| receiver->set(index, cast_value);
|
| }
|
| - return Heap::NumberFromInt32(cast_value);
|
| + return heap->NumberFromInt32(cast_value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) {
|
| return ExternalArrayIntSetter<ExternalByteArray, int8_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalShortArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalShortArray, int16_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index,
|
| Object* value) {
|
| return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) {
|
| return ExternalArrayIntSetter<ExternalIntArray, int32_t>
|
| - (this, index, value);
|
| + (GetHeap(), this, index, value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
|
| uint32_t cast_value = 0;
|
| + Heap* heap = GetHeap();
|
| if (index < static_cast<uint32_t>(length())) {
|
| if (value->IsSmi()) {
|
| int int_value = Smi::cast(value)->value();
|
| @@ -8957,12 +9049,13 @@
|
| }
|
| set(index, cast_value);
|
| }
|
| - return Heap::NumberFromUint32(cast_value);
|
| + return heap->NumberFromUint32(cast_value);
|
| }
|
|
|
|
|
| MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
|
| float cast_value = 0;
|
| + Heap* heap = GetHeap();
|
| if (index < static_cast<uint32_t>(length())) {
|
| if (value->IsSmi()) {
|
| int int_value = Smi::cast(value)->value();
|
| @@ -8977,7 +9070,7 @@
|
| }
|
| set(index, cast_value);
|
| }
|
| - return Heap::AllocateHeapNumber(cast_value);
|
| + return heap->AllocateHeapNumber(cast_value);
|
| }
|
|
|
|
|
| @@ -8990,11 +9083,12 @@
|
|
|
| MaybeObject* GlobalObject::EnsurePropertyCell(String* name) {
|
| ASSERT(!HasFastProperties());
|
| + Heap* heap = GetHeap();
|
| int entry = property_dictionary()->FindEntry(name);
|
| if (entry == StringDictionary::kNotFound) {
|
| Object* cell;
|
| { MaybeObject* maybe_cell =
|
| - Heap::AllocateJSGlobalPropertyCell(Heap::the_hole_value());
|
| + heap->AllocateJSGlobalPropertyCell(heap->the_hole_value());
|
| if (!maybe_cell->ToObject(&cell)) return maybe_cell;
|
| }
|
| PropertyDetails details(NONE, NORMAL);
|
| @@ -9166,9 +9260,10 @@
|
|
|
|
|
| Object* CompilationCacheTable::Lookup(String* src) {
|
| + Heap* heap = GetHeap();
|
| StringKey key(src);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9178,16 +9273,17 @@
|
| StrictModeFlag strict_mode) {
|
| StringSharedKey key(src, context->closure()->shared(), strict_mode);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return GetHeap()->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
|
|
| Object* CompilationCacheTable::LookupRegExp(String* src,
|
| JSRegExp::Flags flags) {
|
| + Heap* heap = GetHeap();
|
| RegExpKey key(src, flags);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9258,12 +9354,13 @@
|
|
|
|
|
| void CompilationCacheTable::Remove(Object* value) {
|
| + Object* null_value = GetHeap()->null_value();
|
| for (int entry = 0, size = Capacity(); entry < size; entry++) {
|
| int entry_index = EntryToIndex(entry);
|
| int value_index = entry_index + 1;
|
| if (get(value_index) == value) {
|
| - fast_set(this, entry_index, Heap::null_value());
|
| - fast_set(this, value_index, Heap::null_value());
|
| + fast_set(this, entry_index, null_value);
|
| + fast_set(this, value_index, null_value);
|
| ElementRemoved();
|
| }
|
| }
|
| @@ -9306,9 +9403,10 @@
|
|
|
|
|
| Object* MapCache::Lookup(FixedArray* array) {
|
| + Heap* heap = GetHeap();
|
| SymbolsKey key(array);
|
| int entry = FindEntry(&key);
|
| - if (entry == kNotFound) return Heap::undefined_value();
|
| + if (entry == kNotFound) return heap->undefined_value();
|
| return get(EntryToIndex(entry) + 1);
|
| }
|
|
|
| @@ -9345,11 +9443,12 @@
|
|
|
| template<typename Shape, typename Key>
|
| MaybeObject* Dictionary<Shape, Key>::GenerateNewEnumerationIndices() {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| int length = HashTable<Shape, Key>::NumberOfElements();
|
|
|
| // Allocate and initialize iteration order array.
|
| Object* obj;
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* iteration_order = FixedArray::cast(obj);
|
| @@ -9358,7 +9457,7 @@
|
| }
|
|
|
| // Allocate array with enumeration order.
|
| - { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
|
| + { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
|
| if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
| }
|
| FixedArray* enumeration_order = FixedArray::cast(obj);
|
| @@ -9419,8 +9518,9 @@
|
| // Do nothing if the interval [from, to) is empty.
|
| if (from >= to) return;
|
|
|
| + Heap* heap = GetHeap();
|
| int removed_entries = 0;
|
| - Object* sentinel = Heap::null_value();
|
| + Object* sentinel = heap->null_value();
|
| int capacity = Capacity();
|
| for (int i = 0; i < capacity; i++) {
|
| Object* key = KeyAt(i);
|
| @@ -9441,14 +9541,15 @@
|
| template<typename Shape, typename Key>
|
| Object* Dictionary<Shape, Key>::DeleteProperty(int entry,
|
| JSObject::DeleteMode mode) {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| PropertyDetails details = DetailsAt(entry);
|
| // Ignore attributes if forcing a deletion.
|
| if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) {
|
| - return Heap::false_value();
|
| + return heap->false_value();
|
| }
|
| - SetEntry(entry, Heap::null_value(), Heap::null_value(), Smi::FromInt(0));
|
| + SetEntry(entry, heap->null_value(), heap->null_value(), Smi::FromInt(0));
|
| HashTable<Shape, Key>::ElementRemoved();
|
| - return Heap::true_value();
|
| + return heap->true_value();
|
| }
|
|
|
|
|
| @@ -9661,6 +9762,7 @@
|
| // Backwards lookup (slow).
|
| template<typename Shape, typename Key>
|
| Object* Dictionary<Shape, Key>::SlowReverseLookup(Object* value) {
|
| + Heap* heap = Dictionary<Shape, Key>::GetHeap();
|
| int capacity = HashTable<Shape, Key>::Capacity();
|
| for (int i = 0; i < capacity; i++) {
|
| Object* k = HashTable<Shape, Key>::KeyAt(i);
|
| @@ -9672,12 +9774,13 @@
|
| if (e == value) return k;
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| MaybeObject* StringDictionary::TransformPropertiesToFastFor(
|
| JSObject* obj, int unused_property_fields) {
|
| + Heap* heap = GetHeap();
|
| // Make sure we preserve dictionary representation if there are too many
|
| // descriptors.
|
| if (NumberOfElements() > DescriptorArray::kMaxNumberOfDescriptors) return obj;
|
| @@ -9707,7 +9810,7 @@
|
| ASSERT(type != FIELD);
|
| instance_descriptor_length++;
|
| if (type == NORMAL &&
|
| - (!value->IsJSFunction() || Heap::InNewSpace(value))) {
|
| + (!value->IsJSFunction() || heap->InNewSpace(value))) {
|
| number_of_fields += 1;
|
| }
|
| }
|
| @@ -9735,7 +9838,7 @@
|
| // Allocate the fixed array for the fields.
|
| Object* fields;
|
| { MaybeObject* maybe_fields =
|
| - Heap::AllocateFixedArray(number_of_allocated_fields);
|
| + heap->AllocateFixedArray(number_of_allocated_fields);
|
| if (!maybe_fields->ToObject(&fields)) return maybe_fields;
|
| }
|
|
|
| @@ -9748,13 +9851,13 @@
|
| Object* value = ValueAt(i);
|
| // Ensure the key is a symbol before writing into the instance descriptor.
|
| Object* key;
|
| - { MaybeObject* maybe_key = Heap::LookupSymbol(String::cast(k));
|
| + { MaybeObject* maybe_key = heap->LookupSymbol(String::cast(k));
|
| if (!maybe_key->ToObject(&key)) return maybe_key;
|
| }
|
| PropertyDetails details = DetailsAt(i);
|
| PropertyType type = details.type();
|
|
|
| - if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
|
| + if (value->IsJSFunction() && !heap->InNewSpace(value)) {
|
| ConstantFunctionDescriptor d(String::cast(key),
|
| JSFunction::cast(value),
|
| details.attributes(),
|
| @@ -9825,11 +9928,12 @@
|
|
|
| // Get the break point info object for this code position.
|
| Object* DebugInfo::GetBreakPointInfo(int code_position) {
|
| + Heap* heap = GetHeap();
|
| // Find the index of the break point info object for this code position.
|
| int index = GetBreakPointInfoIndex(code_position);
|
|
|
| // Return the break point info object if any.
|
| - if (index == kNoBreakPointInfo) return Heap::undefined_value();
|
| + if (index == kNoBreakPointInfo) return heap->undefined_value();
|
| return BreakPointInfo::cast(break_points()->get(index));
|
| }
|
|
|
| @@ -9851,6 +9955,7 @@
|
| int source_position,
|
| int statement_position,
|
| Handle<Object> break_point_object) {
|
| + Isolate* isolate = Isolate::Current();
|
| Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position));
|
| if (!break_point_info->IsUndefined()) {
|
| BreakPointInfo::SetBreakPoint(
|
| @@ -9873,8 +9978,9 @@
|
| Handle<FixedArray> old_break_points =
|
| Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
|
| Handle<FixedArray> new_break_points =
|
| - Factory::NewFixedArray(old_break_points->length() +
|
| - Debug::kEstimatedNofBreakPointsInFunction);
|
| + isolate->factory()->NewFixedArray(
|
| + old_break_points->length() +
|
| + Debug::kEstimatedNofBreakPointsInFunction);
|
|
|
| debug_info->set_break_points(*new_break_points);
|
| for (int i = 0; i < old_break_points->length(); i++) {
|
| @@ -9885,13 +9991,14 @@
|
| ASSERT(index != kNoBreakPointInfo);
|
|
|
| // Allocate new BreakPointInfo object and set the break point.
|
| - Handle<BreakPointInfo> new_break_point_info =
|
| - Handle<BreakPointInfo>::cast(Factory::NewStruct(BREAK_POINT_INFO_TYPE));
|
| + Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
|
| + isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE));
|
| new_break_point_info->set_code_position(Smi::FromInt(code_position));
|
| new_break_point_info->set_source_position(Smi::FromInt(source_position));
|
| new_break_point_info->
|
| set_statement_position(Smi::FromInt(statement_position));
|
| - new_break_point_info->set_break_point_objects(Heap::undefined_value());
|
| + new_break_point_info->set_break_point_objects(
|
| + isolate->heap()->undefined_value());
|
| BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
|
| debug_info->break_points()->set(index, *new_break_point_info);
|
| }
|
| @@ -9899,9 +10006,10 @@
|
|
|
| // Get the break point objects for a code position.
|
| Object* DebugInfo::GetBreakPointObjects(int code_position) {
|
| + Heap* heap = GetHeap();
|
| Object* break_point_info = GetBreakPointInfo(code_position);
|
| if (break_point_info->IsUndefined()) {
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
| return BreakPointInfo::cast(break_point_info)->break_point_objects();
|
| }
|
| @@ -9924,7 +10032,8 @@
|
|
|
| Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
|
| Handle<Object> break_point_object) {
|
| - if (debug_info->break_points()->IsUndefined()) return Heap::undefined_value();
|
| + Heap* heap = Isolate::Current()->heap();
|
| + if (debug_info->break_points()->IsUndefined()) return heap->undefined_value();
|
| for (int i = 0; i < debug_info->break_points()->length(); i++) {
|
| if (!debug_info->break_points()->get(i)->IsUndefined()) {
|
| Handle<BreakPointInfo> break_point_info =
|
| @@ -9936,7 +10045,7 @@
|
| }
|
| }
|
| }
|
| - return Heap::undefined_value();
|
| + return heap->undefined_value();
|
| }
|
|
|
|
|
| @@ -9960,12 +10069,14 @@
|
| // Remove the specified break point object.
|
| void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
|
| Handle<Object> break_point_object) {
|
| + Isolate* isolate = Isolate::Current();
|
| // If there are no break points just ignore.
|
| if (break_point_info->break_point_objects()->IsUndefined()) return;
|
| // If there is a single break point clear it if it is the same.
|
| if (!break_point_info->break_point_objects()->IsFixedArray()) {
|
| if (break_point_info->break_point_objects() == *break_point_object) {
|
| - break_point_info->set_break_point_objects(Heap::undefined_value());
|
| + break_point_info->set_break_point_objects(
|
| + isolate->heap()->undefined_value());
|
| }
|
| return;
|
| }
|
| @@ -9975,7 +10086,7 @@
|
| Handle<FixedArray>(
|
| FixedArray::cast(break_point_info->break_point_objects()));
|
| Handle<FixedArray> new_array =
|
| - Factory::NewFixedArray(old_array->length() - 1);
|
| + isolate->factory()->NewFixedArray(old_array->length() - 1);
|
| int found_count = 0;
|
| for (int i = 0; i < old_array->length(); i++) {
|
| if (old_array->get(i) == *break_point_object) {
|
| @@ -10002,7 +10113,7 @@
|
| if (break_point_info->break_point_objects() == *break_point_object) return;
|
| // If there was one break point object before replace with array.
|
| if (!break_point_info->break_point_objects()->IsFixedArray()) {
|
| - Handle<FixedArray> array = Factory::NewFixedArray(2);
|
| + Handle<FixedArray> array = FACTORY->NewFixedArray(2);
|
| array->set(0, break_point_info->break_point_objects());
|
| array->set(1, *break_point_object);
|
| break_point_info->set_break_point_objects(*array);
|
| @@ -10013,7 +10124,7 @@
|
| Handle<FixedArray>(
|
| FixedArray::cast(break_point_info->break_point_objects()));
|
| Handle<FixedArray> new_array =
|
| - Factory::NewFixedArray(old_array->length() + 1);
|
| + FACTORY->NewFixedArray(old_array->length() + 1);
|
| for (int i = 0; i < old_array->length(); i++) {
|
| // If the break point was there before just ignore.
|
| if (old_array->get(i) == *break_point_object) return;
|
|
|