From fb6776e84a62ea86076aa29ac0b682cbee15ce07 Mon Sep 17 00:00:00 2001 From: "svenpanne@chromium.org" Date: Mon, 25 Feb 2013 14:46:09 +0000 Subject: [PATCH] Made Isolate a mandatory parameter for everything Handle-related. Unified parameter order of CreateHandle with the rest of v8 on the way. A few Isolate::Current()s had to be introduced, which is not nice, and not every place will win a beauty contest, but we can clean this up later easily in smaller steps. Review URL: https://codereview.chromium.org/12300018 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13717 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/accessors.cc | 17 +- src/api.cc | 89 ++++---- src/arm/full-codegen-arm.cc | 3 +- src/arm/lithium-codegen-arm.cc | 5 +- src/arm/macro-assembler-arm.cc | 9 +- src/arm/macro-assembler-arm.h | 2 +- src/arm/stub-cache-arm.cc | 7 +- src/assembler.cc | 15 +- src/assembler.h | 6 +- src/bootstrapper.cc | 44 ++-- src/code-stubs-hydrogen.cc | 5 +- src/code-stubs.cc | 10 +- src/compiler.cc | 4 +- src/compiler.h | 1 + src/contexts.cc | 15 +- src/debug.cc | 53 +++-- src/deoptimizer.cc | 6 +- src/deoptimizer.h | 19 +- src/disassembler.cc | 18 +- src/disassembler.h | 2 +- src/elements.cc | 2 +- src/execution.cc | 31 +-- src/execution.h | 2 +- src/factory.cc | 16 +- src/frames.h | 2 +- src/handles-inl.h | 45 ++-- src/handles.cc | 36 ++- src/handles.h | 33 +-- src/heap.cc | 2 +- src/hydrogen-instructions.cc | 24 +- src/hydrogen-instructions.h | 23 +- src/hydrogen.cc | 39 ++-- src/hydrogen.h | 2 +- src/ia32/assembler-ia32.cc | 2 +- src/ia32/full-codegen-ia32.cc | 3 +- src/ia32/lithium-codegen-ia32.cc | 5 +- src/ia32/macro-assembler-ia32.cc | 6 +- src/ia32/macro-assembler-ia32.h | 2 +- src/ia32/stub-cache-ia32.cc | 7 +- src/ic.cc | 33 +-- src/isolate.cc | 19 +- src/isolate.h | 9 +- src/json-parser.h | 3 +- src/json-stringifier.h | 20 +- src/jsregexp.cc | 4 +- src/lithium.cc | 2 +- src/liveedit.cc | 85 ++++--- src/messages.cc | 22 +- src/messages.h | 2 +- src/mips/full-codegen-mips.cc | 3 +- src/mips/lithium-codegen-mips.cc | 5 +- src/mips/macro-assembler-mips.cc | 6 +- src/mips/macro-assembler-mips.h | 2 +- src/mips/stub-cache-mips.cc | 7 +- src/objects.cc | 96 ++++---- src/runtime.cc | 355 +++++++++++++++-------------- src/serialize.cc | 6 +- src/stub-cache.cc | 2 +- src/x64/full-codegen-x64.cc | 3 +- src/x64/lithium-codegen-x64.cc | 5 +- src/x64/macro-assembler-x64.cc | 6 +- src/x64/stub-cache-x64.cc | 7 +- test/cctest/test-accessors.cc | 5 +- test/cctest/test-api.cc | 3 +- test/cctest/test-assembler-arm.cc | 91 ++++---- test/cctest/test-assembler-ia32.cc | 73 +++--- test/cctest/test-assembler-mips.cc | 30 +-- test/cctest/test-assembler-x64.cc | 8 +- test/cctest/test-compiler.cc | 17 +- test/cctest/test-debug.cc | 18 +- test/cctest/test-disasm-ia32.cc | 5 +- test/cctest/test-disasm-x64.cc | 2 +- test/cctest/test-heap-profiler.cc | 5 +- test/cctest/test-heap.cc | 112 +++++---- test/cctest/test-serialize.cc | 4 +- test/cctest/test-strings.cc | 22 +- test/cctest/test-weakmaps.cc | 16 +- 77 files changed, 944 insertions(+), 781 deletions(-) diff --git a/src/accessors.cc b/src/accessors.cc index bc77af130c..942009a894 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -573,7 +573,8 @@ static MaybeObject* ConstructArgumentsObjectForInlinedFunction( JavaScriptFrame* frame, Handle inlined_function, int inlined_frame_index) { - Factory* factory = Isolate::Current()->factory(); + Isolate* isolate = inlined_function->GetIsolate(); + Factory* factory = isolate->factory(); Vector args_slots = SlotRef::ComputeSlotMappingForArguments( frame, @@ -584,7 +585,7 @@ static MaybeObject* ConstructArgumentsObjectForInlinedFunction( factory->NewArgumentsObject(inlined_function, args_count); Handle array = factory->NewFixedArray(args_count); for (int i = 0; i < args_count; ++i) { - Handle value = args_slots[i].GetValue(); + Handle value = args_slots[i].GetValue(isolate); array->set(i, *value); } arguments->set_elements(*array); @@ -807,14 +808,16 @@ MaybeObject* Accessors::ObjectSetPrototype(JSObject* receiver_raw, Isolate* isolate = receiver_raw->GetIsolate(); HandleScope scope(isolate); Handle receiver(receiver_raw); - Handle value(value_raw); - Handle old_value(GetPrototypeSkipHiddenPrototypes(*receiver)); + Handle value(value_raw, isolate); + Handle old_value(GetPrototypeSkipHiddenPrototypes(*receiver), + isolate); MaybeObject* result = receiver->SetPrototype(*value, kSkipHiddenPrototypes); Handle hresult; if (!result->ToHandle(&hresult, isolate)) return result; - Handle new_value(GetPrototypeSkipHiddenPrototypes(*receiver)); + Handle new_value(GetPrototypeSkipHiddenPrototypes(*receiver), + isolate); if (!new_value->SameValue(*old_value)) { JSObject::EnqueueChangeRecord(receiver, "prototype", isolate->factory()->Proto_symbol(), @@ -843,15 +846,15 @@ static v8::Handle ModuleGetExport( ASSERT(context->IsModuleContext()); int slot = info.Data()->Int32Value(); Object* value = context->get(slot); + Isolate* isolate = instance->GetIsolate(); if (value->IsTheHole()) { Handle name = v8::Utils::OpenHandle(*property); - Isolate* isolate = instance->GetIsolate(); isolate->ScheduleThrow( *isolate->factory()->NewReferenceError("not_defined", HandleVector(&name, 1))); return v8::Handle(); } - return v8::Utils::ToLocal(Handle(value)); + return v8::Utils::ToLocal(Handle(value, isolate)); } diff --git a/src/api.cc b/src/api.cc index 602219791b..1860e507dd 100644 --- a/src/api.cc +++ b/src/api.cc @@ -704,27 +704,29 @@ void HandleScope::Leave() { int HandleScope::NumberOfHandles() { - EnsureInitializedForIsolate( - i::Isolate::Current(), "HandleScope::NumberOfHandles"); - return i::HandleScope::NumberOfHandles(); + i::Isolate* isolate = i::Isolate::Current(); + if (!EnsureInitializedForIsolate(isolate, "HandleScope::NumberOfHandles")) { + return 0; + } + return i::HandleScope::NumberOfHandles(isolate); } i::Object** HandleScope::CreateHandle(i::Object* value) { - return i::HandleScope::CreateHandle(value, i::Isolate::Current()); + return i::HandleScope::CreateHandle(i::Isolate::Current(), value); } i::Object** HandleScope::CreateHandle(i::Isolate* isolate, i::Object* value) { ASSERT(isolate == i::Isolate::Current()); - return i::HandleScope::CreateHandle(value, isolate); + return i::HandleScope::CreateHandle(isolate, value); } i::Object** HandleScope::CreateHandle(i::HeapObject* value) { ASSERT(value->IsHeapObject()); return reinterpret_cast( - i::HandleScope::CreateHandle(value, value->GetIsolate())); + i::HandleScope::CreateHandle(value->GetIsolate(), value)); } @@ -938,7 +940,7 @@ void Template::Set(v8::Handle name, v8::Handle value, if (IsDeadCheck(isolate, "v8::Template::Set()")) return; ENTER_V8(isolate); i::HandleScope scope(isolate); - i::Handle list(Utils::OpenHandle(this)->property_list()); + i::Handle list(Utils::OpenHandle(this)->property_list(), isolate); if (list->IsUndefined()) { list = NeanderArray().value(); Utils::OpenHandle(this)->set_property_list(*list); @@ -964,7 +966,8 @@ Local FunctionTemplate::PrototypeTemplate() { return Local(); } ENTER_V8(isolate); - i::Handle result(Utils::OpenHandle(this)->prototype_template()); + i::Handle result(Utils::OpenHandle(this)->prototype_template(), + isolate); if (result->IsUndefined()) { result = Utils::OpenHandle(*ObjectTemplate::New()); Utils::OpenHandle(this)->set_prototype_template(*result); @@ -1144,7 +1147,8 @@ void FunctionTemplate::AddInstancePropertyAccessor( i::Handle obj = MakeAccessorInfo(name, getter, setter, data, settings, attributes, signature); - i::Handle list(Utils::OpenHandle(this)->property_accessors()); + i::Handle list(Utils::OpenHandle(this)->property_accessors(), + isolate); if (list->IsUndefined()) { list = NeanderArray().value(); Utils::OpenHandle(this)->set_property_accessors(*list); @@ -1694,10 +1698,10 @@ Local Script::Id() { i::HandleScope scope(isolate); i::Handle function_info = OpenScript(this); i::Handle script(i::Script::cast(function_info->script())); - i::Handle id(script->id()); + i::Handle id(script->id(), isolate); raw_id = *id; } - i::Handle id(raw_id); + i::Handle id(raw_id, isolate); return Utils::ToLocal(id); } @@ -1783,7 +1787,7 @@ v8::Local v8::TryCatch::StackTrace() const { i::Handle obj(i::JSObject::cast(raw_obj), isolate_); i::Handle name = isolate_->factory()->stack_symbol(); if (!obj->HasProperty(*name)) return v8::Local(); - i::Handle value = i::GetProperty(obj, name); + i::Handle value = i::GetProperty(isolate_, obj, name); if (value.is_null()) return v8::Local(); return v8::Utils::ToLocal(scope.CloseAndEscape(value)); } else { @@ -1829,7 +1833,7 @@ Local Message::Get() const { ENTER_V8(isolate); HandleScope scope; i::Handle obj = Utils::OpenHandle(this); - i::Handle raw_result = i::MessageHandler::GetMessage(obj); + i::Handle raw_result = i::MessageHandler::GetMessage(isolate, obj); Local result = Utils::ToLocal(raw_result); return scope.Close(result); } @@ -1846,8 +1850,10 @@ v8::Handle Message::GetScriptResourceName() const { i::Handle::cast(Utils::OpenHandle(this)); // Return this.script.name. i::Handle script = - i::Handle::cast(i::Handle(message->script())); - i::Handle resource_name(i::Script::cast(script->value())->name()); + i::Handle::cast(i::Handle(message->script(), + isolate)); + i::Handle resource_name(i::Script::cast(script->value())->name(), + isolate); return scope.Close(Utils::ToLocal(resource_name)); } @@ -1863,8 +1869,9 @@ v8::Handle Message::GetScriptData() const { i::Handle::cast(Utils::OpenHandle(this)); // Return this.script.data. i::Handle script = - i::Handle::cast(i::Handle(message->script())); - i::Handle data(i::Script::cast(script->value())->data()); + i::Handle::cast(i::Handle(message->script(), + isolate)); + i::Handle data(i::Script::cast(script->value())->data(), isolate); return scope.Close(Utils::ToLocal(data)); } @@ -1878,7 +1885,7 @@ v8::Handle Message::GetStackTrace() const { HandleScope scope; i::Handle message = i::Handle::cast(Utils::OpenHandle(this)); - i::Handle stackFramesObj(message->stack_frames()); + i::Handle stackFramesObj(message->stack_frames(), isolate); if (!stackFramesObj->IsJSArray()) return v8::Handle(); i::Handle stackTrace = i::Handle::cast(stackFramesObj); @@ -2430,7 +2437,7 @@ Local Value::ToBoolean() const { } LOG_API(isolate, "ToBoolean"); ENTER_V8(isolate); - i::Handle val = i::Execution::ToBoolean(obj); + i::Handle val = i::Execution::ToBoolean(isolate, obj); return Local(ToApi(val)); } } @@ -2594,7 +2601,7 @@ bool Value::BooleanValue() const { if (IsDeadCheck(isolate, "v8::Value::BooleanValue()")) return false; LOG_API(isolate, "BooleanValue"); ENTER_V8(isolate); - i::Handle value = i::Execution::ToBoolean(obj); + i::Handle value = i::Execution::ToBoolean(isolate, obj); return value->IsTrue(); } } @@ -2697,7 +2704,7 @@ Local Value::ToArrayIndex() const { if (str->AsArrayIndex(&index)) { i::Handle value; if (index <= static_cast(i::Smi::kMaxValue)) { - value = i::Handle(i::Smi::FromInt(index)); + value = i::Handle(i::Smi::FromInt(index), isolate); } else { value = isolate->factory()->NewNumber(index); } @@ -2906,7 +2913,7 @@ Local v8::Object::Get(v8::Handle key) { i::Handle self = Utils::OpenHandle(this); i::Handle key_obj = Utils::OpenHandle(*key); EXCEPTION_PREAMBLE(isolate); - i::Handle result = i::GetProperty(self, key_obj); + i::Handle result = i::GetProperty(isolate, self, key_obj); has_pending_exception = result.is_null(); EXCEPTION_BAILOUT_CHECK(isolate, Local()); return Utils::ToLocal(result); @@ -2952,7 +2959,7 @@ Local v8::Object::GetPrototype() { return Local()); ENTER_V8(isolate); i::Handle self = Utils::OpenHandle(this); - i::Handle result(self->GetPrototype()); + i::Handle result(self->GetPrototype(), isolate); return Utils::ToLocal(result); } @@ -3041,7 +3048,7 @@ Local v8::Object::ObjectProtoToString() { ENTER_V8(isolate); i::Handle self = Utils::OpenHandle(this); - i::Handle name(self->class_name()); + i::Handle name(self->class_name(), isolate); // Native implementation of Object.prototype.toString (v8natives.js): // var c = %ClassOf(this); @@ -3094,7 +3101,7 @@ Local v8::Object::GetConstructor() { return Local()); ENTER_V8(isolate); i::Handle self = Utils::OpenHandle(this); - i::Handle constructor(self->GetConstructor()); + i::Handle constructor(self->GetConstructor(), isolate); return Utils::ToLocal(constructor); } @@ -3725,7 +3732,7 @@ Local Function::Call(v8::Handle recv, int argc, EXCEPTION_BAILOUT_CHECK_DO_CALLBACK(isolate, Local()); raw_result = *returned; } - i::Handle result(raw_result); + i::Handle result(raw_result, isolate); return Utils::ToLocal(result); } @@ -3741,13 +3748,15 @@ void Function::SetName(v8::Handle name) { Handle Function::GetName() const { i::Handle func = Utils::OpenHandle(this); - return Utils::ToLocal(i::Handle(func->shared()->name())); + return Utils::ToLocal(i::Handle(func->shared()->name(), + func->GetIsolate())); } Handle Function::GetInferredName() const { i::Handle func = Utils::OpenHandle(this); - return Utils::ToLocal(i::Handle(func->shared()->inferred_name())); + return Utils::ToLocal(i::Handle(func->shared()->inferred_name(), + func->GetIsolate())); } @@ -3793,7 +3802,7 @@ Handle Function::GetScriptId() const { if (!func->shared()->script()->IsScript()) return v8::Undefined(); i::Handle script(i::Script::cast(func->shared()->script())); - return Utils::ToLocal(i::Handle(script->id())); + return Utils::ToLocal(i::Handle(script->id(), func->GetIsolate())); } int String::Length() const { @@ -4616,7 +4625,7 @@ Handle v8::Context::GetSecurityToken() { } i::Handle env = Utils::OpenHandle(this); i::Object* security_token = env->security_token(); - i::Handle token_handle(security_token); + i::Handle token_handle(security_token, isolate); return Utils::ToLocal(token_handle); } @@ -4752,7 +4761,7 @@ void Context::SetErrorMessageForCodeGenerationFromStrings( i::Object** ctx = reinterpret_cast(this); i::Handle context = i::Handle::cast(i::Handle(ctx)); - i::Handle error_handle = Utils::OpenHandle(*error); + i::Handle error_handle = Utils::OpenHandle(*error); context->set_error_message_for_code_gen_from_strings(*error_handle); } @@ -5037,8 +5046,10 @@ Local v8::BooleanObject::New(bool value) { EnsureInitializedForIsolate(isolate, "v8::BooleanObject::New()"); LOG_API(isolate, "BooleanObject::New"); ENTER_V8(isolate); - i::Handle boolean(value ? isolate->heap()->true_value() - : isolate->heap()->false_value()); + i::Handle boolean(value + ? isolate->heap()->true_value() + : isolate->heap()->false_value(), + isolate); i::Handle obj = isolate->factory()->ToObject(boolean); return Utils::ToLocal(obj); } @@ -5692,7 +5703,7 @@ Local Exception::RangeError(v8::Handle raw_message) { i::Handle result = isolate->factory()->NewRangeError(message); error = *result; } - i::Handle result(error); + i::Handle result(error, isolate); return Utils::ToLocal(result); } @@ -5709,7 +5720,7 @@ Local Exception::ReferenceError(v8::Handle raw_message) { isolate->factory()->NewReferenceError(message); error = *result; } - i::Handle result(error); + i::Handle result(error, isolate); return Utils::ToLocal(result); } @@ -5725,7 +5736,7 @@ Local Exception::SyntaxError(v8::Handle raw_message) { i::Handle result = isolate->factory()->NewSyntaxError(message); error = *result; } - i::Handle result(error); + i::Handle result(error, isolate); return Utils::ToLocal(result); } @@ -5741,7 +5752,7 @@ Local Exception::TypeError(v8::Handle raw_message) { i::Handle result = isolate->factory()->NewTypeError(message); error = *result; } - i::Handle result(error); + i::Handle result(error, isolate); return Utils::ToLocal(result); } @@ -5757,7 +5768,7 @@ Local Exception::Error(v8::Handle raw_message) { i::Handle result = isolate->factory()->NewError(message); error = *result; } - i::Handle result(error); + i::Handle result(error, isolate); return Utils::ToLocal(result); } @@ -5961,7 +5972,7 @@ Local Debug::GetMirror(v8::Handle obj) { i::Handle debug(isolate_debug->debug_context()->global_object()); i::Handle name = isolate->factory()->LookupOneByteSymbol( STATIC_ASCII_VECTOR("MakeMirror")); - i::Handle fun_obj = i::GetProperty(debug, name); + i::Handle fun_obj = i::GetProperty(isolate, debug, name); i::Handle fun = i::Handle::cast(fun_obj); v8::Handle v8_fun = Utils::ToLocal(fun); const int kArgc = 1; diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index cb83860d6a..9ccae5a0ad 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -1164,7 +1164,8 @@ void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) { Handle cell = isolate()->factory()->NewJSGlobalPropertyCell( Handle( - Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker))); + Smi::FromInt(TypeFeedbackCells::kForInFastCaseMarker), + isolate())); RecordTypeFeedbackCell(stmt->ForInFeedbackId(), cell); __ LoadHeapObject(r1, cell); __ mov(r2, Operand(Smi::FromInt(TypeFeedbackCells::kForInSlowCaseMarker))); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index faeb841d30..bad66fe821 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -5740,7 +5740,8 @@ void LCodeGen::EmitDeepCopy(Handle object, // Copy in-object properties. for (int i = 0; i < inobject_properties; i++) { int total_offset = object_offset + object->GetInObjectPropertyOffset(i); - Handle value = Handle(object->InObjectPropertyAt(i)); + Handle value = Handle(object->InObjectPropertyAt(i), + isolate()); if (value->IsJSObject()) { Handle value_object = Handle::cast(value); __ add(r2, result, Operand(*offset)); @@ -5794,7 +5795,7 @@ void LCodeGen::EmitDeepCopy(Handle object, Handle fast_elements = Handle::cast(elements); for (int i = 0; i < elements_length; i++) { int total_offset = elements_offset + FixedArray::OffsetOfElementAt(i); - Handle value(fast_elements->get(i)); + Handle value(fast_elements->get(i), isolate()); if (value->IsJSObject()) { Handle value_object = Handle::cast(value); __ add(r2, result, Operand(*offset)); diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 6796f7388a..c1a3881c3e 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -425,7 +425,8 @@ void MacroAssembler::LoadRoot(Register destination, if (CpuFeatures::IsSupported(MOVW_MOVT_IMMEDIATE_LOADS) && !Heap::RootCanBeWrittenAfterInitialization(index) && !predictable_code_size()) { - Handle root(isolate()->heap()->roots_array_start()[index]); + Handle root(isolate()->heap()->roots_array_start()[index], + isolate()); if (!isolate()->heap()->InNewSpace(*root)) { // The CPU supports fast immediate values, and this root will never // change. We will load it as a relocatable immediate value. @@ -2241,13 +2242,13 @@ static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, int stack_space) { ExternalReference next_address = - ExternalReference::handle_scope_next_address(); + ExternalReference::handle_scope_next_address(isolate()); const int kNextOffset = 0; const int kLimitOffset = AddressOffset( - ExternalReference::handle_scope_limit_address(), + ExternalReference::handle_scope_limit_address(isolate()), next_address); const int kLevelOffset = AddressOffset( - ExternalReference::handle_scope_level_address(), + ExternalReference::handle_scope_level_address(isolate()), next_address); // Allocate HandleScope in callee-save registers. diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index 93760bd203..dc4529bf7c 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -308,7 +308,7 @@ class MacroAssembler: public Assembler { // Push a handle. void Push(Handle handle); - void Push(Smi* smi) { Push(Handle(smi)); } + void Push(Smi* smi) { Push(Handle(smi, isolate())); } // Push two registers. Pushes leftmost register first (to highest address). void Push(Register src1, Register src2, Condition cond = al) { diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index 50bd22f53b..05d2773755 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -711,7 +711,7 @@ static void GenerateFastApiDirectCall(MacroAssembler* masm, // Pass the additional arguments. Handle api_call_info = optimization.api_call_info(); - Handle call_data(api_call_info->data()); + Handle call_data(api_call_info->data(), masm->isolate()); if (masm->isolate()->heap()->InNewSpace(*call_data)) { __ Move(r0, api_call_info); __ ldr(r6, FieldMemOperand(r0, CallHandlerInfo::kDataOffset)); @@ -1283,7 +1283,7 @@ void StubCompiler::GenerateLoadCallback( __ ldr(scratch3, FieldMemOperand(scratch3, ExecutableAccessorInfo::kDataOffset)); } else { - __ Move(scratch3, Handle(callback->data())); + __ Move(scratch3, Handle(callback->data(), isolate())); } __ Push(reg, scratch3); __ mov(scratch3, Operand(ExternalReference::isolate_address())); @@ -3338,7 +3338,8 @@ Handle ConstructStubCompiler::CompileConstructStub( __ bind(&next); } else { // Set the property to the constant value. - Handle constant(shared->GetThisPropertyAssignmentConstant(i)); + Handle constant(shared->GetThisPropertyAssignmentConstant(i), + isolate()); __ mov(r2, Operand(constant)); __ str(r2, MemOperand(r5, kPointerSize, PostIndex)); } diff --git a/src/assembler.cc b/src/assembler.cc index fdb6399da5..199fa0d46a 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -1157,18 +1157,21 @@ ExternalReference ExternalReference::new_space_allocation_limit_address( } -ExternalReference ExternalReference::handle_scope_level_address() { - return ExternalReference(HandleScope::current_level_address()); +ExternalReference ExternalReference::handle_scope_level_address( + Isolate* isolate) { + return ExternalReference(HandleScope::current_level_address(isolate)); } -ExternalReference ExternalReference::handle_scope_next_address() { - return ExternalReference(HandleScope::current_next_address()); +ExternalReference ExternalReference::handle_scope_next_address( + Isolate* isolate) { + return ExternalReference(HandleScope::current_next_address(isolate)); } -ExternalReference ExternalReference::handle_scope_limit_address() { - return ExternalReference(HandleScope::current_limit_address()); +ExternalReference ExternalReference::handle_scope_limit_address( + Isolate* isolate) { + return ExternalReference(HandleScope::current_limit_address(isolate)); } diff --git a/src/assembler.h b/src/assembler.h index 0b12375599..461bbde249 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -724,9 +724,9 @@ class ExternalReference BASE_EMBEDDED { static ExternalReference power_double_double_function(Isolate* isolate); static ExternalReference power_double_int_function(Isolate* isolate); - static ExternalReference handle_scope_next_address(); - static ExternalReference handle_scope_limit_address(); - static ExternalReference handle_scope_level_address(); + static ExternalReference handle_scope_next_address(Isolate* isolate); + static ExternalReference handle_scope_limit_address(Isolate* isolate); + static ExternalReference handle_scope_level_address(Isolate* isolate); static ExternalReference scheduled_exception_address(Isolate* isolate); static ExternalReference address_of_pending_message_obj(Isolate* isolate); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index b318faca6a..6487dc991d 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -86,7 +86,8 @@ Handle Bootstrapper::NativesSourceLookup(int index) { isolate_->factory()->NewExternalStringFromAscii(resource); heap->natives_source_cache()->set(index, *source_code); } - Handle cached_source(heap->natives_source_cache()->get(index)); + Handle cached_source(heap->natives_source_cache()->get(index), + isolate_); return Handle::cast(cached_source); } @@ -722,7 +723,8 @@ Handle Genesis::CreateNewGlobals( Handle global_constructor = Handle( FunctionTemplateInfo::cast(data->constructor())); - Handle proto_template(global_constructor->prototype_template()); + Handle proto_template(global_constructor->prototype_template(), + isolate()); if (!proto_template->IsUndefined()) { js_global_template = Handle::cast(proto_template); @@ -1389,7 +1391,8 @@ bool Genesis::CompileScriptCached(Isolate* isolate, Handle receiver = Handle(use_runtime_context ? top_context->builtins() - : top_context->global_object()); + : top_context->global_object(), + isolate); bool has_pending_exception; Execution::Call(fun, receiver, 0, NULL, &has_pending_exception); if (has_pending_exception) return false; @@ -1532,7 +1535,7 @@ bool Genesis::InstallNatives() { static_cast(READ_ONLY | DONT_DELETE); Handle global_symbol = factory()->LookupOneByteSymbol(STATIC_ASCII_VECTOR("global")); - Handle global_obj(native_context()->global_object()); + Handle global_obj(native_context()->global_object(), isolate()); CHECK_NOT_EMPTY_HANDLE(isolate(), JSObject::SetLocalPropertyIgnoreAttributes( builtins, global_symbol, global_obj, attributes)); @@ -1767,7 +1770,8 @@ bool Genesis::InstallNatives() { // Install Function.prototype.call and apply. { Handle key = factory()->function_class_symbol(); Handle function = - Handle::cast(GetProperty(isolate()->global_object(), key)); + Handle::cast( + GetProperty(isolate(), isolate()->global_object(), key)); Handle proto = Handle(JSObject::cast(function->instance_prototype())); @@ -1896,18 +1900,19 @@ bool Genesis::InstallExperimentalNatives() { static Handle ResolveBuiltinIdHolder( Handle native_context, const char* holder_expr) { - Factory* factory = native_context->GetIsolate()->factory(); + Isolate* isolate = native_context->GetIsolate(); + Factory* factory = isolate->factory(); Handle global(native_context->global_object()); const char* period_pos = strchr(holder_expr, '.'); if (period_pos == NULL) { return Handle::cast( - GetProperty(global, factory->LookupUtf8Symbol(holder_expr))); + GetProperty(isolate, global, factory->LookupUtf8Symbol(holder_expr))); } ASSERT_EQ(".prototype", period_pos); Vector property(holder_expr, static_cast(period_pos - holder_expr)); Handle function = Handle::cast( - GetProperty(global, factory->LookupUtf8Symbol(property))); + GetProperty(isolate, global, factory->LookupUtf8Symbol(property))); return Handle(JSObject::cast(function->prototype())); } @@ -2018,7 +2023,8 @@ void Genesis::InstallSpecialObjects(Handle native_context) { if (Error->IsJSObject()) { Handle name = factory->LookupOneByteSymbol(STATIC_ASCII_VECTOR("stackTraceLimit")); - Handle stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit)); + Handle stack_trace_limit(Smi::FromInt(FLAG_stack_trace_limit), + isolate); CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( Handle::cast(Error), name, @@ -2040,7 +2046,8 @@ void Genesis::InstallSpecialObjects(Handle native_context) { Handle debug_string = factory->LookupUtf8Symbol(FLAG_expose_debug_as); - Handle global_proxy(debug->debug_context()->global_proxy()); + Handle global_proxy(debug->debug_context()->global_proxy(), + isolate); CHECK_NOT_EMPTY_HANDLE(isolate, JSObject::SetLocalPropertyIgnoreAttributes( global, debug_string, global_proxy, DONT_ENUM)); @@ -2255,8 +2262,9 @@ void Genesis::TransferNamedProperties(Handle from, HandleScope inner(isolate()); Handle key = Handle(descs->GetKey(i)); int index = descs->GetFieldIndex(i); - Handle value = Handle(from->FastPropertyAt(index)); - CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), + Handle value = Handle(from->FastPropertyAt(index), + isolate()); + CHECK_NOT_EMPTY_HANDLE(isolate(), JSObject::SetLocalPropertyIgnoreAttributes( to, key, value, details.attributes())); break; @@ -2266,7 +2274,7 @@ void Genesis::TransferNamedProperties(Handle from, Handle key = Handle(descs->GetKey(i)); Handle fun = Handle(descs->GetConstantFunction(i)); - CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), + CHECK_NOT_EMPTY_HANDLE(isolate(), JSObject::SetLocalPropertyIgnoreAttributes( to, key, fun, details.attributes())); break; @@ -2280,7 +2288,7 @@ void Genesis::TransferNamedProperties(Handle from, ASSERT(!to->HasFastProperties()); // Add to dictionary. Handle key = Handle(descs->GetKey(i)); - Handle callbacks(descs->GetCallbacksObject(i)); + Handle callbacks(descs->GetCallbacksObject(i), isolate()); PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, details.descriptor_index()); @@ -2312,12 +2320,14 @@ void Genesis::TransferNamedProperties(Handle from, if (result.IsFound()) continue; // Set the property. Handle key = Handle(String::cast(raw_key)); - Handle value = Handle(properties->ValueAt(i)); + Handle value = Handle(properties->ValueAt(i), + isolate()); if (value->IsJSGlobalPropertyCell()) { - value = Handle(JSGlobalPropertyCell::cast(*value)->value()); + value = Handle(JSGlobalPropertyCell::cast(*value)->value(), + isolate()); } PropertyDetails details = properties->DetailsAt(i); - CHECK_NOT_EMPTY_HANDLE(to->GetIsolate(), + CHECK_NOT_EMPTY_HANDLE(isolate(), JSObject::SetLocalPropertyIgnoreAttributes( to, key, value, details.attributes())); } diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 525c28ee85..3421ef8717 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -36,9 +36,10 @@ namespace internal { static LChunk* OptimizeGraph(HGraph* graph) { + Isolate* isolate = graph->isolate(); AssertNoAllocation no_gc; - NoHandleAllocation no_handles; - NoHandleDereference no_deref; + NoHandleAllocation no_handles(isolate); + NoHandleDereference no_deref(isolate); ASSERT(graph != NULL); SmartArrayPointer bailout_reason; diff --git a/src/code-stubs.cc b/src/code-stubs.cc index 5e3795ce69..1df313debd 100644 --- a/src/code-stubs.cc +++ b/src/code-stubs.cc @@ -308,12 +308,10 @@ bool ICCompareStub::FindCodeInSpecialCache(Code** code_out, Isolate* isolate) { static_cast(GetCodeKind()), UNINITIALIZED); ASSERT(op_ == Token::EQ || op_ == Token::EQ_STRICT); - Handle probe( - known_map_->FindInCodeCache( - strict() ? - *factory->strict_compare_ic_symbol() : - *factory->compare_ic_symbol(), - flags)); + String* symbol = strict() ? + *factory->strict_compare_ic_symbol() : + *factory->compare_ic_symbol(); + Handle probe(known_map_->FindInCodeCache(symbol, flags), isolate); if (probe->IsCode()) { *code_out = Code::cast(*probe); #ifdef DEBUG diff --git a/src/compiler.cc b/src/compiler.cc index 3bd00a928b..43d57fa700 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -394,8 +394,8 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { OptimizingCompiler::Status OptimizingCompiler::OptimizeGraph() { AssertNoAllocation no_gc; - NoHandleAllocation no_handles; - NoHandleDereference no_deref; + NoHandleAllocation no_handles(isolate()); + NoHandleDereference no_deref(isolate()); ASSERT(last_status() == SUCCEEDED); Timer t(this, &time_taken_to_optimize_); diff --git a/src/compiler.h b/src/compiler.h index 076dc003f6..4d7644c7ff 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -424,6 +424,7 @@ class OptimizingCompiler: public ZoneObject { Status last_status() const { return last_status_; } CompilationInfo* info() const { return info_; } + Isolate* isolate() const { return info()->isolate(); } MUST_USE_RESULT Status AbortOptimization() { info_->AbortOptimization(); diff --git a/src/contexts.cc b/src/contexts.cc index 4cb52d3a6c..5edbc5ac2d 100644 --- a/src/contexts.cc +++ b/src/contexts.cc @@ -327,14 +327,11 @@ void Context::ClearOptimizedFunctions() { Handle Context::ErrorMessageForCodeGenerationFromStrings() { - Handle result(error_message_for_code_gen_from_strings()); - if (result->IsUndefined()) { - const char* error = - "Code generation from strings disallowed for this context"; - Isolate* isolate = Isolate::Current(); - result = isolate->factory()->NewStringFromAscii(i::CStrVector(error)); - } - return result; + Handle result(error_message_for_code_gen_from_strings(), + GetIsolate()); + if (!result->IsUndefined()) return result; + return GetIsolate()->factory()->NewStringFromAscii(i::CStrVector( + "Code generation from strings disallowed for this context")); } @@ -343,7 +340,7 @@ bool Context::IsBootstrappingOrValidParentContext( Object* object, Context* child) { // During bootstrapping we allow all objects to pass as // contexts. This is necessary to fix circular dependencies. - if (Isolate::Current()->bootstrapper()->IsActive()) return true; + if (child->GetIsolate()->bootstrapper()->IsActive()) return true; if (!object->IsContext()) return false; Context* context = Context::cast(object); return context->IsNativeContext() || context->IsGlobalContext() || diff --git a/src/debug.cc b/src/debug.cc index 587bade704..8940edd15a 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -778,8 +778,11 @@ bool Debug::CompileDebuggerScript(int index) { factory->NewFunctionFromSharedFunctionInfo(function_info, context); Handle exception = - Execution::TryCall(function, Handle(context->global_object()), - 0, NULL, &caught_exception); + Execution::TryCall(function, + Handle(context->global_object(), isolate), + 0, + NULL, + &caught_exception); // Check for caught exceptions. if (caught_exception) { @@ -844,8 +847,11 @@ bool Debug::Load() { Handle global = Handle(context->global_object()); RETURN_IF_EMPTY_HANDLE_VALUE( isolate_, - JSReceiver::SetProperty(global, key, Handle(global->builtins()), - NONE, kNonStrictMode), + JSReceiver::SetProperty(global, + key, + Handle(global->builtins(), isolate_), + NONE, + kNonStrictMode), false); // Compile the JavaScript for the debugger in the debugger context. @@ -950,10 +956,10 @@ Object* Debug::Break(Arguments args) { // If there is one or more real break points check whether any of these are // triggered. - Handle break_points_hit(heap->undefined_value()); + Handle break_points_hit(heap->undefined_value(), isolate_); if (break_location_iterator.HasBreakPoint()) { Handle break_point_objects = - Handle(break_location_iterator.BreakPointObjects()); + Handle(break_location_iterator.BreakPointObjects(), isolate_); break_points_hit = CheckBreakPoints(break_point_objects); } @@ -1071,7 +1077,7 @@ Handle Debug::CheckBreakPoints(Handle break_point_objects) { Handle array(FixedArray::cast(*break_point_objects)); break_points_hit = factory->NewFixedArray(array->length()); for (int i = 0; i < array->length(); i++) { - Handle o(array->get(i)); + Handle o(array->get(i), isolate_); if (CheckBreakPoint(o)) { break_points_hit->set(break_points_hit_count++, *o); } @@ -1294,7 +1300,8 @@ void Debug::FloodWithOneShot(Handle function) { void Debug::FloodBoundFunctionWithOneShot(Handle function) { Handle new_bindings(function->function_bindings()); - Handle bindee(new_bindings->get(JSFunction::kBoundFunctionIndex)); + Handle bindee(new_bindings->get(JSFunction::kBoundFunctionIndex), + isolate_); if (!bindee.is_null() && bindee->IsJSFunction() && !JSFunction::cast(*bindee)->IsBuiltin()) { @@ -1492,7 +1499,8 @@ void Debug::PrepareStep(StepAction step_action, int step_count) { // from the code object. Handle obj( isolate_->heap()->code_stubs()->SlowReverseLookup( - *call_function_stub)); + *call_function_stub), + isolate_); ASSERT(!obj.is_null()); ASSERT(!(*obj)->IsUndefined()); ASSERT(obj->IsSmi()); @@ -1665,10 +1673,12 @@ Handle Debug::GetSourceBreakLocations( Handle shared) { Isolate* isolate = Isolate::Current(); Heap* heap = isolate->heap(); - if (!HasDebugInfo(shared)) return Handle(heap->undefined_value()); + if (!HasDebugInfo(shared)) { + return Handle(heap->undefined_value(), isolate); + } Handle debug_info = GetDebugInfo(shared); if (debug_info->GetBreakPointCount() == 0) { - return Handle(heap->undefined_value()); + return Handle(heap->undefined_value(), isolate); } Handle locations = isolate->factory()->NewFixedArray(debug_info->GetBreakPointCount()); @@ -2434,8 +2444,8 @@ void Debug::ClearMirrorCache() { Handle function_name = isolate_->factory()->LookupOneByteSymbol( STATIC_ASCII_VECTOR("ClearMirrorCache")); Handle fun( - Isolate::Current()->global_object()->GetPropertyNoExceptionThrown( - *function_name)); + isolate_->global_object()->GetPropertyNoExceptionThrown(*function_name), + isolate_); ASSERT(fun->IsJSFunction()); bool caught_exception; Execution::TryCall(Handle::cast(fun), @@ -2562,8 +2572,8 @@ Handle Debugger::MakeJSObject(Vector constructor_name, Handle constructor_str = isolate_->factory()->LookupUtf8Symbol(constructor_name); Handle constructor( - isolate_->global_object()->GetPropertyNoExceptionThrown( - *constructor_str)); + isolate_->global_object()->GetPropertyNoExceptionThrown(*constructor_str), + isolate_); ASSERT(constructor->IsJSFunction()); if (!constructor->IsJSFunction()) { *caught_exception = true; @@ -2651,7 +2661,7 @@ Handle Debugger::MakeScriptCollectedEvent(int id, bool* caught_exception) { // Create the script collected event object. Handle exec_state = MakeExecutionState(caught_exception); - Handle id_object = Handle(Smi::FromInt(id)); + Handle id_object = Handle(Smi::FromInt(id), isolate_); Handle argv[] = { exec_state, id_object }; return MakeJSObject(CStrVector("MakeScriptCollectedEvent"), @@ -2794,8 +2804,10 @@ void Debugger::OnAfterCompile(Handle