From 26eae0c429780744b3714354c24d128234690d6e Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Tue, 1 Jul 2014 12:12:34 +0000 Subject: [PATCH] Clean up the global object naming madness. BUG= R=ishell@chromium.org Review URL: https://codereview.chromium.org/352173006 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22117 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/accessors.cc | 5 +- src/api.cc | 37 ++-- src/arm/builtins-arm.cc | 20 +- src/arm/full-codegen-arm.cc | 2 +- src/arm/lithium-codegen-arm.cc | 5 +- src/arm/stub-cache-arm.cc | 6 +- src/arm64/builtins-arm64.cc | 20 +- src/arm64/full-codegen-arm64.cc | 2 +- src/arm64/lithium-codegen-arm64.cc | 4 +- src/arm64/stub-cache-arm64.cc | 6 +- src/bootstrapper.cc | 211 ++++++++++----------- src/bootstrapper.h | 4 +- src/builtins.cc | 4 +- src/debug.cc | 19 +- src/execution.cc | 14 +- src/factory.cc | 14 +- src/factory.h | 8 +- src/generator.js | 4 +- src/heap-snapshot-generator.cc | 4 +- src/hydrogen.cc | 9 +- src/ia32/builtins-ia32.cc | 20 +- src/ia32/full-codegen-ia32.cc | 2 +- src/ia32/lithium-codegen-ia32.cc | 6 +- src/ia32/stub-cache-ia32.cc | 4 +- src/ic-inl.h | 2 +- src/ic.cc | 2 +- src/isolate.cc | 4 +- src/isolate.h | 6 +- src/objects-inl.h | 9 +- src/objects.h | 9 +- src/proxy.js | 4 +- src/runtime.cc | 44 ++--- src/runtime.h | 2 +- src/v8natives.js | 16 +- src/x64/builtins-x64.cc | 20 +- src/x64/full-codegen-x64.cc | 2 +- src/x64/lithium-codegen-x64.cc | 5 +- src/x64/stub-cache-x64.cc | 4 +- test/cctest/test-heap-profiler.cc | 6 +- .../{globalreceiver.js => globalproxy.js} | 2 +- 40 files changed, 270 insertions(+), 297 deletions(-) rename test/mjsunit/runtime-gen/{globalreceiver.js => globalproxy.js} (88%) diff --git a/src/accessors.cc b/src/accessors.cc index aeea430..836b4f5 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -153,10 +153,9 @@ Handle Accessors::FlattenNumber(Isolate* isolate, Handle value) { if (value->IsNumber() || !value->IsJSValue()) return value; Handle wrapper = Handle::cast(value); - ASSERT(wrapper->GetIsolate()->context()->native_context()->number_function()-> + ASSERT(wrapper->GetIsolate()->native_context()->number_function()-> has_initial_map()); - if (wrapper->map() == - isolate->context()->native_context()->number_function()->initial_map()) { + if (wrapper->map() == isolate->number_function()->initial_map()) { return handle(wrapper->value(), isolate); } diff --git a/src/api.cc b/src/api.cc index cb26f6f..a324726 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1647,8 +1647,7 @@ Local Script::Run() { i::HandleScope scope(isolate); i::Handle fun = i::Handle::cast(obj); EXCEPTION_PREAMBLE(isolate); - i::Handle receiver( - isolate->context()->global_proxy(), isolate); + i::Handle receiver(isolate->global_proxy(), isolate); i::Handle result; has_pending_exception = !i::Execution::Call( isolate, fun, receiver, 0, NULL).ToHandle(&result); @@ -5105,7 +5104,7 @@ static i::Handle CreateEnvironment( i::Isolate* isolate, v8::ExtensionConfiguration* extensions, v8::Handle global_template, - v8::Handle global_object) { + v8::Handle maybe_global_proxy) { i::Handle env; // Enter V8 via an ENTER_V8 scope. @@ -5143,11 +5142,14 @@ static i::Handle CreateEnvironment( } } + i::Handle proxy = Utils::OpenHandle(*maybe_global_proxy, true); + i::MaybeHandle maybe_proxy; + if (!proxy.is_null()) { + maybe_proxy = i::Handle::cast(proxy); + } // Create the environment. env = isolate->bootstrapper()->CreateEnvironment( - Utils::OpenHandle(*global_object, true), - proxy_template, - extensions); + maybe_proxy, proxy_template, extensions); // Restore the access check info on the global template. if (!global_template.IsEmpty()) { @@ -5826,8 +5828,7 @@ bool Value::IsPromise() const { i::Handle b; has_pending_exception = !i::Execution::Call( isolate, - handle( - isolate->context()->global_object()->native_context()->is_promise()), + isolate->is_promise(), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, false).ToHandle(&b); @@ -5844,8 +5845,7 @@ Local Promise::Resolver::New(Isolate* v8_isolate) { i::Handle result; has_pending_exception = !i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_create()), + isolate->promise_create(), isolate->factory()->undefined_value(), 0, NULL, false).ToHandle(&result); @@ -5869,8 +5869,7 @@ void Promise::Resolver::Resolve(Handle value) { i::Handle argv[] = { promise, Utils::OpenHandle(*value) }; has_pending_exception = i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_resolve()), + isolate->promise_resolve(), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, false).is_null(); @@ -5887,8 +5886,7 @@ void Promise::Resolver::Reject(Handle value) { i::Handle argv[] = { promise, Utils::OpenHandle(*value) }; has_pending_exception = i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_reject()), + isolate->promise_reject(), isolate->factory()->undefined_value(), ARRAY_SIZE(argv), argv, false).is_null(); @@ -5906,8 +5904,7 @@ Local Promise::Chain(Handle handler) { i::Handle result; has_pending_exception = !i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_chain()), + isolate->promise_chain(), promise, ARRAY_SIZE(argv), argv, false).ToHandle(&result); @@ -5926,8 +5923,7 @@ Local Promise::Catch(Handle handler) { i::Handle result; has_pending_exception = !i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_catch()), + isolate->promise_catch(), promise, ARRAY_SIZE(argv), argv, false).ToHandle(&result); @@ -5946,8 +5942,7 @@ Local Promise::Then(Handle handler) { i::Handle result; has_pending_exception = !i::Execution::Call( isolate, - handle(isolate->context()->global_object()->native_context()-> - promise_then()), + isolate->promise_then(), promise, ARRAY_SIZE(argv), argv, false).ToHandle(&result); @@ -6382,7 +6377,7 @@ v8::Local Isolate::GetCurrentContext() { i::Isolate* isolate = reinterpret_cast(this); i::Context* context = isolate->context(); if (context == NULL) return Local(); - i::Context* native_context = context->global_object()->native_context(); + i::Context* native_context = context->native_context(); if (native_context == NULL) return Local(); return Utils::ToLocal(i::Handle(native_context)); } diff --git a/src/arm/builtins-arm.cc b/src/arm/builtins-arm.cc index c022d7c..62543dc 100644 --- a/src/arm/builtins-arm.cc +++ b/src/arm/builtins-arm.cc @@ -1071,7 +1071,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // r1: function Label shift_arguments; __ mov(r4, Operand::Zero()); // indicate regular JS_FUNCTION - { Label convert_to_object, use_global_receiver, patch_receiver; + { Label convert_to_object, use_global_proxy, patch_receiver; // Change context eagerly in case we need the global receiver. __ ldr(cp, FieldMemOperand(r1, JSFunction::kContextOffset)); @@ -1096,10 +1096,10 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ LoadRoot(r3, Heap::kUndefinedValueRootIndex); __ cmp(r2, r3); - __ b(eq, &use_global_receiver); + __ b(eq, &use_global_proxy); __ LoadRoot(r3, Heap::kNullValueRootIndex); __ cmp(r2, r3); - __ b(eq, &use_global_receiver); + __ b(eq, &use_global_proxy); STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); __ CompareObjectType(r2, r3, r3, FIRST_SPEC_OBJECT_TYPE); @@ -1128,9 +1128,9 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ mov(r4, Operand::Zero()); __ jmp(&patch_receiver); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ ldr(r2, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); - __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); + __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); __ bind(&patch_receiver); __ add(r3, sp, Operand(r0, LSL, kPointerSizeLog2)); @@ -1284,7 +1284,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { // Compute the receiver. // Do not transform the receiver for strict mode functions. - Label call_to_object, use_global_receiver; + Label call_to_object, use_global_proxy; __ ldr(r2, FieldMemOperand(r2, SharedFunctionInfo::kCompilerHintsOffset)); __ tst(r2, Operand(1 << (SharedFunctionInfo::kStrictModeFunction + kSmiTagSize))); @@ -1298,10 +1298,10 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ JumpIfSmi(r0, &call_to_object); __ LoadRoot(r1, Heap::kNullValueRootIndex); __ cmp(r0, r1); - __ b(eq, &use_global_receiver); + __ b(eq, &use_global_proxy); __ LoadRoot(r1, Heap::kUndefinedValueRootIndex); __ cmp(r0, r1); - __ b(eq, &use_global_receiver); + __ b(eq, &use_global_proxy); // Check if the receiver is already a JavaScript object. // r0: receiver @@ -1316,9 +1316,9 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION); __ b(&push_receiver); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ ldr(r0, ContextOperand(cp, Context::GLOBAL_OBJECT_INDEX)); - __ ldr(r0, FieldMemOperand(r0, GlobalObject::kGlobalReceiverOffset)); + __ ldr(r0, FieldMemOperand(r0, GlobalObject::kGlobalProxyOffset)); // Push the receiver. // r0: receiver diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index dd2cab4..c5576df 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -133,7 +133,7 @@ void FullCodeGenerator::Generate() { __ b(ne, &ok); __ ldr(r2, GlobalObjectOperand()); - __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); + __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); __ str(r2, MemOperand(sp, receiver_offset)); diff --git a/src/arm/lithium-codegen-arm.cc b/src/arm/lithium-codegen-arm.cc index fb89186..7d76086 100644 --- a/src/arm/lithium-codegen-arm.cc +++ b/src/arm/lithium-codegen-arm.cc @@ -130,7 +130,7 @@ bool LCodeGen::GeneratePrologue() { __ b(ne, &ok); __ ldr(r2, GlobalObjectOperand()); - __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset)); + __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset)); __ str(r2, MemOperand(sp, receiver_offset)); @@ -3472,8 +3472,7 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { __ ldr(result, FieldMemOperand(function, JSFunction::kContextOffset)); __ ldr(result, ContextOperand(result, Context::GLOBAL_OBJECT_INDEX)); - __ ldr(result, - FieldMemOperand(result, GlobalObject::kGlobalReceiverOffset)); + __ ldr(result, FieldMemOperand(result, GlobalObject::kGlobalProxyOffset)); if (result.is(receiver)) { __ bind(&result_in_receiver); diff --git a/src/arm/stub-cache-arm.cc b/src/arm/stub-cache-arm.cc index ab83e86..bdf04c0 100644 --- a/src/arm/stub-cache-arm.cc +++ b/src/arm/stub-cache-arm.cc @@ -1203,8 +1203,7 @@ void StoreStubCompiler::GenerateStoreViaSetter( if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ ldr(receiver, - FieldMemOperand( - receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ Push(receiver, value()); ParameterCount actual(1); @@ -1319,8 +1318,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ ldr(receiver, - FieldMemOperand( - receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ push(receiver); ParameterCount actual(0); diff --git a/src/arm64/builtins-arm64.cc b/src/arm64/builtins-arm64.cc index aea4533..31b61f4 100644 --- a/src/arm64/builtins-arm64.cc +++ b/src/arm64/builtins-arm64.cc @@ -1065,7 +1065,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // 3a. Patch the first argument if necessary when calling a function. Label shift_arguments; __ Mov(call_type, static_cast(call_type_JS_func)); - { Label convert_to_object, use_global_receiver, patch_receiver; + { Label convert_to_object, use_global_proxy, patch_receiver; // Change context eagerly in case we need the global receiver. __ Ldr(cp, FieldMemOperand(function, JSFunction::kContextOffset)); @@ -1089,8 +1089,8 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ JumpIfSmi(receiver, &convert_to_object); __ JumpIfRoot(receiver, Heap::kUndefinedValueRootIndex, - &use_global_receiver); - __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, &use_global_receiver); + &use_global_proxy); + __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, &use_global_proxy); STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); __ JumpIfObjectType(receiver, scratch1, scratch2, @@ -1118,10 +1118,10 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ Mov(call_type, static_cast(call_type_JS_func)); __ B(&patch_receiver); - __ Bind(&use_global_receiver); + __ Bind(&use_global_proxy); __ Ldr(receiver, GlobalObjectMemOperand()); __ Ldr(receiver, - FieldMemOperand(receiver, GlobalObject::kGlobalReceiverOffset)); + FieldMemOperand(receiver, GlobalObject::kGlobalProxyOffset)); __ Bind(&patch_receiver); @@ -1278,7 +1278,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { // Compute and push the receiver. // Do not transform the receiver for strict mode functions. - Label convert_receiver_to_object, use_global_receiver; + Label convert_receiver_to_object, use_global_proxy; __ Ldr(w10, FieldMemOperand(x2, SharedFunctionInfo::kCompilerHintsOffset)); __ Tbnz(x10, SharedFunctionInfo::kStrictModeFunction, &push_receiver); // Do not transform the receiver for native functions. @@ -1286,9 +1286,9 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { // Compute the receiver in sloppy mode. __ JumpIfSmi(receiver, &convert_receiver_to_object); - __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, &use_global_receiver); + __ JumpIfRoot(receiver, Heap::kNullValueRootIndex, &use_global_proxy); __ JumpIfRoot(receiver, Heap::kUndefinedValueRootIndex, - &use_global_receiver); + &use_global_proxy); // Check if the receiver is already a JavaScript object. STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); @@ -1302,9 +1302,9 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ Mov(receiver, x0); __ B(&push_receiver); - __ Bind(&use_global_receiver); + __ Bind(&use_global_proxy); __ Ldr(x10, GlobalObjectMemOperand()); - __ Ldr(receiver, FieldMemOperand(x10, GlobalObject::kGlobalReceiverOffset)); + __ Ldr(receiver, FieldMemOperand(x10, GlobalObject::kGlobalProxyOffset)); // Push the receiver __ Bind(&push_receiver); diff --git a/src/arm64/full-codegen-arm64.cc b/src/arm64/full-codegen-arm64.cc index 6b8e49c..37c9ed3 100644 --- a/src/arm64/full-codegen-arm64.cc +++ b/src/arm64/full-codegen-arm64.cc @@ -130,7 +130,7 @@ void FullCodeGenerator::Generate() { __ JumpIfNotRoot(x10, Heap::kUndefinedValueRootIndex, &ok); __ Ldr(x10, GlobalObjectMemOperand()); - __ Ldr(x10, FieldMemOperand(x10, GlobalObject::kGlobalReceiverOffset)); + __ Ldr(x10, FieldMemOperand(x10, GlobalObject::kGlobalProxyOffset)); __ Poke(x10, receiver_offset); __ Bind(&ok); diff --git a/src/arm64/lithium-codegen-arm64.cc b/src/arm64/lithium-codegen-arm64.cc index 52f2b45..ed6fde3 100644 --- a/src/arm64/lithium-codegen-arm64.cc +++ b/src/arm64/lithium-codegen-arm64.cc @@ -661,7 +661,7 @@ bool LCodeGen::GeneratePrologue() { __ JumpIfNotRoot(x10, Heap::kUndefinedValueRootIndex, &ok); __ Ldr(x10, GlobalObjectMemOperand()); - __ Ldr(x10, FieldMemOperand(x10, GlobalObject::kGlobalReceiverOffset)); + __ Ldr(x10, FieldMemOperand(x10, GlobalObject::kGlobalProxyOffset)); __ Poke(x10, receiver_offset); __ Bind(&ok); @@ -5948,7 +5948,7 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { __ Bind(&global_object); __ Ldr(result, FieldMemOperand(function, JSFunction::kContextOffset)); __ Ldr(result, ContextMemOperand(result, Context::GLOBAL_OBJECT_INDEX)); - __ Ldr(result, FieldMemOperand(result, GlobalObject::kGlobalReceiverOffset)); + __ Ldr(result, FieldMemOperand(result, GlobalObject::kGlobalProxyOffset)); __ B(&done); __ Bind(©_receiver); diff --git a/src/arm64/stub-cache-arm64.cc b/src/arm64/stub-cache-arm64.cc index e3d4f8d..a0ce997 100644 --- a/src/arm64/stub-cache-arm64.cc +++ b/src/arm64/stub-cache-arm64.cc @@ -1175,8 +1175,7 @@ void StoreStubCompiler::GenerateStoreViaSetter( if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ Ldr(receiver, - FieldMemOperand( - receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ Push(receiver, value()); ParameterCount actual(1); @@ -1295,8 +1294,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ Ldr(receiver, - FieldMemOperand( - receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldMemOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ Push(receiver); ParameterCount actual(0); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index a2d1388..72ca6bf 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -148,8 +148,8 @@ void Bootstrapper::TearDown() { class Genesis BASE_EMBEDDED { public: Genesis(Isolate* isolate, - Handle global_object, - v8::Handle global_template, + MaybeHandle maybe_global_proxy, + v8::Handle global_proxy_template, v8::ExtensionConfiguration* extensions); ~Genesis() { } @@ -183,20 +183,20 @@ class Genesis BASE_EMBEDDED { // we have to used the deserialized ones that are linked together with the // rest of the context snapshot. Handle CreateNewGlobals( - v8::Handle global_template, - Handle global_object, - Handle* global_proxy_out); + v8::Handle global_proxy_template, + MaybeHandle maybe_global_proxy, + Handle* global_object_out); // Hooks the given global proxy into the context. If the context was created // by deserialization then this will unhook the global proxy that was // deserialized, leaving the GC to pick it up. - void HookUpGlobalProxy(Handle inner_global, + void HookUpGlobalProxy(Handle global_object, Handle global_proxy); - // Similarly, we want to use the inner global that has been created by the - // templates passed through the API. The inner global from the snapshot is - // detached from the other objects in the snapshot. - void HookUpInnerGlobal(Handle inner_global); + // Similarly, we want to use the global that has been created by the templates + // passed through the API. The global from the snapshot is detached from the + // other objects in the snapshot. + void HookUpGlobalObject(Handle global_object); // New context initialization. Used for creating a context from scratch. - void InitializeGlobal(Handle inner_global, + void InitializeGlobal(Handle global_object, Handle empty_function); void InitializeExperimentalGlobal(); // Installs the contents of the native .js files on the global objects. @@ -253,7 +253,8 @@ class Genesis BASE_EMBEDDED { bool InstallJSBuiltins(Handle builtins); bool ConfigureApiObject(Handle object, Handle object_template); - bool ConfigureGlobalObjects(v8::Handle global_template); + bool ConfigureGlobalObjects( + v8::Handle global_proxy_template); // Migrates all properties from the 'from' object to the 'to' // object and overrides the prototype in 'to' with the one from @@ -327,11 +328,12 @@ void Bootstrapper::Iterate(ObjectVisitor* v) { Handle Bootstrapper::CreateEnvironment( - Handle global_object, - v8::Handle global_template, + MaybeHandle maybe_global_proxy, + v8::Handle global_proxy_template, v8::ExtensionConfiguration* extensions) { HandleScope scope(isolate_); - Genesis genesis(isolate_, global_object, global_template, extensions); + Genesis genesis( + isolate_, maybe_global_proxy, global_proxy_template, extensions); Handle env = genesis.result(); if (env.is_null() || !InstallExtensions(env, extensions)) { return Handle(); @@ -729,73 +731,74 @@ void Genesis::CreateRoots() { Handle Genesis::CreateNewGlobals( - v8::Handle global_template, - Handle global_object, - Handle* inner_global_out) { - // The argument global_template aka data is an ObjectTemplateInfo. + v8::Handle global_proxy_template, + MaybeHandle maybe_global_proxy, + Handle* global_object_out) { + // The argument global_proxy_template aka data is an ObjectTemplateInfo. // It has a constructor pointer that points at global_constructor which is a // FunctionTemplateInfo. - // The global_constructor is used to create or reinitialize the global_proxy. - // The global_constructor also has a prototype_template pointer that points at - // js_global_template which is an ObjectTemplateInfo. + // The global_proxy_constructor is used to create or reinitialize the + // global_proxy. The global_proxy_constructor also has a prototype_template + // pointer that points at js_global_object_template which is an + // ObjectTemplateInfo. // That in turn has a constructor pointer that points at - // js_global_constructor which is a FunctionTemplateInfo. - // js_global_constructor is used to make js_global_function - // js_global_function is used to make the new inner_global. + // js_global_object_constructor which is a FunctionTemplateInfo. + // js_global_object_constructor is used to make js_global_object_function + // js_global_object_function is used to make the new global_object. // // --- G l o b a l --- - // Step 1: Create a fresh inner JSGlobalObject. - Handle js_global_function; - Handle js_global_template; - if (!global_template.IsEmpty()) { - // Get prototype template of the global_template. + // Step 1: Create a fresh JSGlobalObject. + Handle js_global_object_function; + Handle js_global_object_template; + if (!global_proxy_template.IsEmpty()) { + // Get prototype template of the global_proxy_template. Handle data = - v8::Utils::OpenHandle(*global_template); + v8::Utils::OpenHandle(*global_proxy_template); Handle global_constructor = Handle( FunctionTemplateInfo::cast(data->constructor())); Handle proto_template(global_constructor->prototype_template(), isolate()); if (!proto_template->IsUndefined()) { - js_global_template = + js_global_object_template = Handle::cast(proto_template); } } - if (js_global_template.is_null()) { + if (js_global_object_template.is_null()) { Handle name = Handle(heap()->empty_string()); Handle code = Handle(isolate()->builtins()->builtin( Builtins::kIllegal)); - js_global_function = factory()->NewFunction( + js_global_object_function = factory()->NewFunction( name, code, JS_GLOBAL_OBJECT_TYPE, JSGlobalObject::kSize); // Change the constructor property of the prototype of the // hidden global function to refer to the Object function. Handle prototype = Handle( - JSObject::cast(js_global_function->instance_prototype())); + JSObject::cast(js_global_object_function->instance_prototype())); JSObject::SetOwnPropertyIgnoreAttributes( prototype, factory()->constructor_string(), isolate()->object_function(), NONE).Check(); } else { - Handle js_global_constructor( - FunctionTemplateInfo::cast(js_global_template->constructor())); - js_global_function = - factory()->CreateApiFunction(js_global_constructor, + Handle js_global_object_constructor( + FunctionTemplateInfo::cast(js_global_object_template->constructor())); + js_global_object_function = + factory()->CreateApiFunction(js_global_object_constructor, factory()->the_hole_value(), - factory()->InnerGlobalObject); + factory()->GlobalObjectType); } - js_global_function->initial_map()->set_is_hidden_prototype(); - js_global_function->initial_map()->set_dictionary_map(true); - Handle inner_global = - factory()->NewGlobalObject(js_global_function); - if (inner_global_out != NULL) { - *inner_global_out = inner_global; + js_global_object_function->initial_map()->set_is_hidden_prototype(); + js_global_object_function->initial_map()->set_dictionary_map(true); + Handle global_object = + factory()->NewGlobalObject(js_global_object_function); + if (global_object_out != NULL) { + *global_object_out = global_object; } // Step 2: create or re-initialize the global proxy object. Handle global_proxy_function; - if (global_template.IsEmpty()) { + if (global_proxy_template.IsEmpty()) { Handle name = Handle(heap()->empty_string()); Handle code = Handle(isolate()->builtins()->builtin( Builtins::kIllegal)); @@ -803,13 +806,13 @@ Handle Genesis::CreateNewGlobals( name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize); } else { Handle data = - v8::Utils::OpenHandle(*global_template); + v8::Utils::OpenHandle(*global_proxy_template); Handle global_constructor( FunctionTemplateInfo::cast(data->constructor())); global_proxy_function = factory()->CreateApiFunction(global_constructor, factory()->the_hole_value(), - factory()->OuterGlobalObject); + factory()->GlobalProxyType); } Handle global_name = factory()->InternalizeOneByteString( @@ -821,9 +824,7 @@ Handle Genesis::CreateNewGlobals( // Return the global proxy. Handle global_proxy; - if (global_object.location() != NULL) { - ASSERT(global_object->IsJSGlobalProxy()); - global_proxy = Handle::cast(global_object); + if (maybe_global_proxy.ToHandle(&global_proxy)) { factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function); } else { global_proxy = Handle::cast( @@ -834,62 +835,61 @@ Handle Genesis::CreateNewGlobals( } -void Genesis::HookUpGlobalProxy(Handle inner_global, +void Genesis::HookUpGlobalProxy(Handle global_object, Handle global_proxy) { // Set the native context for the global object. - inner_global->set_native_context(*native_context()); - inner_global->set_global_context(*native_context()); - inner_global->set_global_receiver(*global_proxy); + global_object->set_native_context(*native_context()); + global_object->set_global_context(*native_context()); + global_object->set_global_proxy(*global_proxy); global_proxy->set_native_context(*native_context()); native_context()->set_global_proxy(*global_proxy); } -void Genesis::HookUpInnerGlobal(Handle inner_global) { - Handle inner_global_from_snapshot( +void Genesis::HookUpGlobalObject(Handle global_object) { + Handle global_object_from_snapshot( GlobalObject::cast(native_context()->extension())); Handle builtins_global(native_context()->builtins()); - native_context()->set_extension(*inner_global); - native_context()->set_global_object(*inner_global); - native_context()->set_security_token(*inner_global); + native_context()->set_extension(*global_object); + native_context()->set_global_object(*global_object); + native_context()->set_security_token(*global_object); static const PropertyAttributes attributes = static_cast(READ_ONLY | DONT_DELETE); Runtime::DefineObjectProperty(builtins_global, factory()->InternalizeOneByteString( STATIC_ASCII_VECTOR("global")), - inner_global, + global_object, attributes).Assert(); // Set up the reference from the global object to the builtins object. - JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global); - TransferNamedProperties(inner_global_from_snapshot, inner_global); - TransferIndexedProperties(inner_global_from_snapshot, inner_global); + JSGlobalObject::cast(*global_object)->set_builtins(*builtins_global); + TransferNamedProperties(global_object_from_snapshot, global_object); + TransferIndexedProperties(global_object_from_snapshot, global_object); } // This is only called if we are not using snapshots. The equivalent -// work in the snapshot case is done in HookUpInnerGlobal. -void Genesis::InitializeGlobal(Handle inner_global, +// work in the snapshot case is done in HookUpGlobalObject. +void Genesis::InitializeGlobal(Handle global_object, Handle empty_function) { // --- N a t i v e C o n t e x t --- // Use the empty function as closure (no scope info). native_context()->set_closure(*empty_function); native_context()->set_previous(NULL); // Set extension and global object. - native_context()->set_extension(*inner_global); - native_context()->set_global_object(*inner_global); - // Security setup: Set the security token of the global object to - // its the inner global. This makes the security check between two - // different contexts fail by default even in case of global - // object reinitialization. - native_context()->set_security_token(*inner_global); - - Isolate* isolate = inner_global->GetIsolate(); + native_context()->set_extension(*global_object); + native_context()->set_global_object(*global_object); + // Security setup: Set the security token of the native context to the global + // object. This makes the security check between two different contexts fail + // by default even in case of global object reinitialization. + native_context()->set_security_token(*global_object); + + Isolate* isolate = global_object->GetIsolate(); Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); Handle object_name = factory->Object_string(); JSObject::AddProperty( - inner_global, object_name, isolate->object_function(), DONT_ENUM); + global_object, object_name, isolate->object_function(), DONT_ENUM); Handle global(native_context()->global_object()); @@ -1719,8 +1719,7 @@ bool Genesis::InstallNatives() { builtins->set_builtins(*builtins); builtins->set_native_context(*native_context()); builtins->set_global_context(*native_context()); - builtins->set_global_receiver(*builtins); - builtins->set_global_receiver(native_context()->global_proxy()); + builtins->set_global_proxy(native_context()->global_proxy()); // Set up the 'global' properties of the builtins object. The @@ -1933,7 +1932,7 @@ bool Genesis::InstallNatives() { { Handle key = factory()->function_class_string(); Handle function = Handle::cast(Object::GetProperty( - isolate()->global_object(), key).ToHandleChecked()); + handle(native_context()->global_object()), key).ToHandleChecked()); Handle proto = Handle(JSObject::cast(function->instance_prototype())); @@ -2386,26 +2385,26 @@ bool Genesis::ConfigureGlobalObjects( v8::Handle global_proxy_template) { Handle global_proxy( JSObject::cast(native_context()->global_proxy())); - Handle inner_global( + Handle global_object( JSObject::cast(native_context()->global_object())); if (!global_proxy_template.IsEmpty()) { // Configure the global proxy object. - Handle proxy_data = + Handle global_proxy_data = v8::Utils::OpenHandle(*global_proxy_template); - if (!ConfigureApiObject(global_proxy, proxy_data)) return false; + if (!ConfigureApiObject(global_proxy, global_proxy_data)) return false; - // Configure the inner global object. + // Configure the global object. Handle proxy_constructor( - FunctionTemplateInfo::cast(proxy_data->constructor())); + FunctionTemplateInfo::cast(global_proxy_data->constructor())); if (!proxy_constructor->prototype_template()->IsUndefined()) { - Handle inner_data( + Handle global_object_data( ObjectTemplateInfo::cast(proxy_constructor->prototype_template())); - if (!ConfigureApiObject(inner_global, inner_data)) return false; + if (!ConfigureApiObject(global_object, global_object_data)) return false; } } - SetObjectPrototype(global_proxy, inner_global); + SetObjectPrototype(global_proxy, global_object); native_context()->set_initial_array_prototype( JSArray::cast(native_context()->array_function()->prototype())); @@ -2415,7 +2414,7 @@ bool Genesis::ConfigureGlobalObjects( bool Genesis::ConfigureApiObject(Handle object, - Handle object_template) { + Handle object_template) { ASSERT(!object_template.is_null()); ASSERT(FunctionTemplateInfo::cast(object_template->constructor()) ->IsTemplateFor(object->map()));; @@ -2573,8 +2572,8 @@ class NoTrackDoubleFieldsForSerializerScope { Genesis::Genesis(Isolate* isolate, - Handle global_object, - v8::Handle global_template, + MaybeHandle maybe_global_proxy, + v8::Handle global_proxy_template, v8::ExtensionConfiguration* extensions) : isolate_(isolate), active_(isolate->bootstrapper()) { @@ -2605,35 +2604,33 @@ Genesis::Genesis(Isolate* isolate, AddToWeakNativeContextList(*native_context()); isolate->set_context(*native_context()); isolate->counters()->contexts_created_by_snapshot()->Increment(); - Handle inner_global; - Handle global_proxy = - CreateNewGlobals(global_template, - global_object, - &inner_global); - - HookUpGlobalProxy(inner_global, global_proxy); - HookUpInnerGlobal(inner_global); - native_context()->builtins()->set_global_receiver( + Handle global_object; + Handle global_proxy = CreateNewGlobals( + global_proxy_template, maybe_global_proxy, &global_object); + + HookUpGlobalProxy(global_object, global_proxy); + HookUpGlobalObject(global_object); + native_context()->builtins()->set_global_proxy( native_context()->global_proxy()); - if (!ConfigureGlobalObjects(global_template)) return; + if (!ConfigureGlobalObjects(global_proxy_template)) return; } else { // We get here if there was no context snapshot. CreateRoots(); Handle empty_function = CreateEmptyFunction(isolate); CreateStrictModeFunctionMaps(empty_function); - Handle inner_global; - Handle global_proxy = - CreateNewGlobals(global_template, global_object, &inner_global); - HookUpGlobalProxy(inner_global, global_proxy); - InitializeGlobal(inner_global, empty_function); + Handle global_object; + Handle global_proxy = CreateNewGlobals( + global_proxy_template, maybe_global_proxy, &global_object); + HookUpGlobalProxy(global_object, global_proxy); + InitializeGlobal(global_object, empty_function); InstallJSFunctionResultCaches(); InitializeNormalizedMapCaches(); if (!InstallNatives()) return; MakeFunctionInstancePrototypeWritable(); - if (!ConfigureGlobalObjects(global_template)) return; + if (!ConfigureGlobalObjects(global_proxy_template)) return; isolate->counters()->contexts_created_from_scratch()->Increment(); } diff --git a/src/bootstrapper.h b/src/bootstrapper.h index 5988382..4743226 100644 --- a/src/bootstrapper.h +++ b/src/bootstrapper.h @@ -76,8 +76,8 @@ class Bootstrapper V8_FINAL { // Creates a JavaScript Global Context with initial object graph. // The returned value is a global handle casted to V8Environment*. Handle CreateEnvironment( - Handle global_object, - v8::Handle global_template, + MaybeHandle maybe_global_proxy, + v8::Handle global_object_template, v8::ExtensionConfiguration* extensions); // Detach the environment from its outer global object. diff --git a/src/builtins.cc b/src/builtins.cc index 512abe3..28c4a78 100644 --- a/src/builtins.cc +++ b/src/builtins.cc @@ -1166,9 +1166,7 @@ MUST_USE_RESULT static Object* HandleApiCallHelper( if (shared->strict_mode() == SLOPPY && !shared->native()) { Object* recv = args[0]; ASSERT(!recv->IsNull()); - if (recv->IsUndefined()) { - args[0] = function->context()->global_object()->global_receiver(); - } + if (recv->IsUndefined()) args[0] = function->global_proxy(); } Object* raw_holder = TypeCheck(heap, args.length(), &args[0], *fun_data); diff --git a/src/debug.cc b/src/debug.cc index 94fdb47..b19b47e 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -759,7 +759,7 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) { Handle exception; MaybeHandle result = Execution::TryCall(function, - Handle(context->global_object(), isolate), + handle(context->global_proxy()), 0, NULL, &exception); @@ -807,7 +807,7 @@ bool Debug::Load() { ExtensionConfiguration no_extensions; Handle context = isolate_->bootstrapper()->CreateEnvironment( - Handle::null(), + MaybeHandle(), v8::Handle(), &no_extensions); @@ -2446,12 +2446,13 @@ void Debug::ClearMirrorCache() { HandleScope scope(isolate_); AssertDebugContext(); Factory* factory = isolate_->factory(); - JSObject::SetProperty(isolate_->global_object(), + Handle global(isolate_->global_object()); + JSObject::SetProperty(global, factory->NewStringFromAsciiChecked("next_handle_"), handle(Smi::FromInt(0), isolate_), NONE, SLOPPY).Check(); - JSObject::SetProperty(isolate_->global_object(), + JSObject::SetProperty(global, factory->NewStringFromAsciiChecked("mirror_cache_"), factory->NewJSArray(0, FAST_ELEMENTS), NONE, @@ -2494,14 +2495,15 @@ MaybeHandle Debug::MakeJSObject(const char* constructor_name, Handle argv[]) { AssertDebugContext(); // Create the execution state object. + Handle global(isolate_->global_object()); Handle constructor = Object::GetProperty( - isolate_, isolate_->global_object(), constructor_name).ToHandleChecked(); + isolate_, global, constructor_name).ToHandleChecked(); ASSERT(constructor->IsJSFunction()); if (!constructor->IsJSFunction()) return MaybeHandle(); // We do not handle interrupts here. In particular, termination interrupts. PostponeInterruptsScope no_interrupts(isolate_); return Execution::TryCall(Handle::cast(constructor), - Handle(debug_context()->global_object()), + handle(debug_context()->global_proxy()), argc, argv); } @@ -2777,10 +2779,9 @@ void Debug::CallEventCallback(v8::DebugEvent event, exec_state, event_data, event_listener_data_ }; + Handle global(isolate_->global_proxy()); Execution::TryCall(Handle::cast(event_listener_), - isolate_->global_object(), - ARRAY_SIZE(argv), - argv); + global, ARRAY_SIZE(argv), argv); } } diff --git a/src/execution.cc b/src/execution.cc index 2766e76..2a2c90a 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -70,8 +70,7 @@ MUST_USE_RESULT static MaybeHandle Invoke( // receiver instead to avoid having a 'this' pointer which refers // directly to a global object. if (receiver->IsGlobalObject()) { - Handle global = Handle::cast(receiver); - receiver = Handle(global->global_receiver()); + receiver = handle(Handle::cast(receiver)->global_proxy()); } // Make sure that the global object of the context we're about to @@ -133,13 +132,8 @@ MaybeHandle Execution::Call(Isolate* isolate, !func->shared()->native() && func->shared()->strict_mode() == SLOPPY) { if (receiver->IsUndefined() || receiver->IsNull()) { - Object* global = func->context()->global_object()->global_receiver(); - // Under some circumstances, 'global' can be the JSBuiltinsObject - // In that case, don't rewrite. (FWIW, the same holds for - // GetIsolate()->global_object()->global_receiver().) - if (!global->IsJSBuiltinsObject()) { - receiver = Handle(global, func->GetIsolate()); - } + receiver = handle(func->global_proxy()); + ASSERT(!receiver->IsJSBuiltinsObject()); } else { ASSIGN_RETURN_ON_EXCEPTION( isolate, receiver, ToObject(isolate, receiver), Object); @@ -153,7 +147,7 @@ MaybeHandle Execution::Call(Isolate* isolate, MaybeHandle Execution::New(Handle func, int argc, Handle argv[]) { - return Invoke(true, func, func->GetIsolate()->global_object(), argc, argv); + return Invoke(true, func, handle(func->global_proxy()), argc, argv); } diff --git a/src/factory.cc b/src/factory.cc index 0f56fca..8e903f1 100644 --- a/src/factory.cc +++ b/src/factory.cc @@ -1244,7 +1244,7 @@ Handle Factory::NewFunction(Handle map, Handle Factory::NewFunction(Handle map, Handle name, MaybeHandle code) { - Handle context(isolate()->context()->native_context()); + Handle context(isolate()->native_context()); Handle info = NewSharedFunctionInfo(name, code); ASSERT((info->strict_mode() == SLOPPY) && (map.is_identical_to(isolate()->sloppy_function_map()) || @@ -1687,7 +1687,7 @@ Handle Factory::NewJSGeneratorObject( Handle Factory::NewJSArrayBuffer() { Handle array_buffer_fun( - isolate()->context()->native_context()->array_buffer_fun()); + isolate()->native_context()->array_buffer_fun()); CALL_HEAP_FUNCTION( isolate(), isolate()->heap()->AllocateJSObject(*array_buffer_fun), @@ -1697,7 +1697,7 @@ Handle Factory::NewJSArrayBuffer() { Handle Factory::NewJSDataView() { Handle data_view_fun( - isolate()->context()->native_context()->data_view_fun()); + isolate()->native_context()->data_view_fun()); CALL_HEAP_FUNCTION( isolate(), isolate()->heap()->AllocateJSObject(*data_view_fun), @@ -1821,7 +1821,7 @@ void Factory::ReinitializeJSReceiver(Handle object, if (type == JS_FUNCTION_TYPE) { map->set_function_with_prototype(true); Handle js_function = Handle::cast(object); - Handle context(isolate()->context()->native_context()); + Handle context(isolate()->native_context()); InitializeFunction(js_function, shared.ToHandleChecked(), context); } } @@ -2117,15 +2117,15 @@ Handle Factory::CreateApiFunction( int instance_size = kPointerSize * internal_field_count; InstanceType type; switch (instance_type) { - case JavaScriptObject: + case JavaScriptObjectType: type = JS_OBJECT_TYPE; instance_size += JSObject::kHeaderSize; break; - case InnerGlobalObject: + case GlobalObjectType: type = JS_GLOBAL_OBJECT_TYPE; instance_size += JSGlobalObject::kSize; break; - case OuterGlobalObject: + case GlobalProxyType: type = JS_GLOBAL_PROXY_TYPE; instance_size += JSGlobalProxy::kSize; break; diff --git a/src/factory.h b/src/factory.h index cad25b5..25051da 100644 --- a/src/factory.h +++ b/src/factory.h @@ -559,15 +559,15 @@ class Factory V8_FINAL { } enum ApiInstanceType { - JavaScriptObject, - InnerGlobalObject, - OuterGlobalObject + JavaScriptObjectType, + GlobalObjectType, + GlobalProxyType }; Handle CreateApiFunction( Handle data, Handle prototype, - ApiInstanceType type = JavaScriptObject); + ApiInstanceType type = JavaScriptObjectType); Handle InstallMembers(Handle function); diff --git a/src/generator.js b/src/generator.js index 14df131..316ffa0 100644 --- a/src/generator.js +++ b/src/generator.js @@ -44,12 +44,12 @@ function GeneratorFunctionPrototypeConstructor(x) { function GeneratorFunctionConstructor(arg1) { // length == 1 var source = NewFunctionString(arguments, 'function*'); - var global_receiver = %GlobalReceiver(global); + var global_proxy = %GlobalProxy(global); // Compile the string in the constructor and not a helper so that errors // appear to come from here. var f = %CompileString(source, true); if (!IS_FUNCTION(f)) return f; - f = %_CallFunction(global_receiver, f); + f = %_CallFunction(global_proxy, f); %FunctionMarkNameShouldPrintAsAnonymous(f); return f; } diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index 097d5a5..80d3c10 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -1216,8 +1216,8 @@ void V8HeapExplorer::ExtractJSObjectReferences( "global_context", global_obj->global_context(), GlobalObject::kGlobalContextOffset); SetInternalReference(global_obj, entry, - "global_receiver", global_obj->global_receiver(), - GlobalObject::kGlobalReceiverOffset); + "global_proxy", global_obj->global_proxy(), + GlobalObject::kGlobalProxyOffset); STATIC_ASSERT(GlobalObject::kHeaderSize - JSObject::kHeaderSize == 4 * kPointerSize); } else if (obj->IsJSArrayBufferView()) { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 0651e71..51f3efe 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -8441,9 +8441,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle function, // as it maybe dropped on deserialization. CHECK(!isolate()->serializer_enabled()); ASSERT_EQ(0, receiver_maps->length()); - receiver_maps->Add(handle( - function->context()->global_object()->global_receiver()->map()), - zone()); + receiver_maps->Add(handle(function->global_proxy()->map()), zone()); } CallOptimization::HolderLookup holder_lookup = CallOptimization::kHolderNotFound; @@ -8628,9 +8626,8 @@ HValue* HOptimizedGraphBuilder::ImplicitReceiverFor(HValue* function, // Cannot embed a direct reference to the global proxy // as is it dropped on deserialization. CHECK(!isolate()->serializer_enabled()); - Handle global_receiver( - target->context()->global_object()->global_receiver()); - return Add(global_receiver); + Handle global_proxy(target->context()->global_proxy()); + return Add(global_proxy); } return graph()->GetConstantUndefined(); } diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc index 0a1c0a5..6b93ddd 100644 --- a/src/ia32/builtins-ia32.cc +++ b/src/ia32/builtins-ia32.cc @@ -765,7 +765,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // 3a. Patch the first argument if necessary when calling a function. Label shift_arguments; __ Move(edx, Immediate(0)); // indicate regular JS_FUNCTION - { Label convert_to_object, use_global_receiver, patch_receiver; + { Label convert_to_object, use_global_proxy, patch_receiver; // Change context eagerly in case we need the global receiver. __ mov(esi, FieldOperand(edi, JSFunction::kContextOffset)); @@ -787,9 +787,9 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // global object if it is null or undefined. __ JumpIfSmi(ebx, &convert_to_object); __ cmp(ebx, factory->null_value()); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); __ cmp(ebx, factory->undefined_value()); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); __ CmpObjectType(ebx, FIRST_SPEC_OBJECT_TYPE, ecx); __ j(above_equal, &shift_arguments); @@ -814,10 +814,10 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ mov(edi, Operand(esp, eax, times_4, 1 * kPointerSize)); __ jmp(&patch_receiver); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); - __ mov(ebx, FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); + __ mov(ebx, FieldOperand(ebx, GlobalObject::kGlobalProxyOffset)); __ bind(&patch_receiver); __ mov(Operand(esp, eax, times_4, 0), ebx); @@ -943,7 +943,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ mov(ebx, Operand(ebp, kReceiverOffset)); // Check that the function is a JS function (otherwise it must be a proxy). - Label push_receiver, use_global_receiver; + Label push_receiver, use_global_proxy; __ mov(edi, Operand(ebp, kFunctionOffset)); __ CmpObjectType(edi, JS_FUNCTION_TYPE, ecx); __ j(not_equal, &push_receiver); @@ -971,9 +971,9 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { // global object if it is null or undefined. __ JumpIfSmi(ebx, &call_to_object); __ cmp(ebx, factory->null_value()); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); __ cmp(ebx, factory->undefined_value()); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); __ CmpObjectType(ebx, FIRST_SPEC_OBJECT_TYPE, ecx); __ j(above_equal, &push_receiver); @@ -984,10 +984,10 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ mov(ebx, eax); __ jmp(&push_receiver); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ mov(ebx, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); - __ mov(ebx, FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset)); + __ mov(ebx, FieldOperand(ebx, GlobalObject::kGlobalProxyOffset)); // Push the receiver. __ bind(&push_receiver); diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index c286d57..fbe41fc 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -123,7 +123,7 @@ void FullCodeGenerator::Generate() { __ j(not_equal, &ok, Label::kNear); __ mov(ecx, GlobalObjectOperand()); - __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); + __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset)); __ mov(Operand(esp, receiver_offset), ecx); diff --git a/src/ia32/lithium-codegen-ia32.cc b/src/ia32/lithium-codegen-ia32.cc index a918298..f43b0a7 100644 --- a/src/ia32/lithium-codegen-ia32.cc +++ b/src/ia32/lithium-codegen-ia32.cc @@ -151,7 +151,7 @@ bool LCodeGen::GeneratePrologue() { __ j(not_equal, &ok, Label::kNear); __ mov(ecx, GlobalObjectOperand()); - __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset)); + __ mov(ecx, FieldOperand(ecx, GlobalObject::kGlobalProxyOffset)); __ mov(Operand(esp, receiver_offset), ecx); @@ -3309,8 +3309,8 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { __ mov(receiver, FieldOperand(function, JSFunction::kContextOffset)); const int global_offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX); __ mov(receiver, Operand(receiver, global_offset)); - const int receiver_offset = GlobalObject::kGlobalReceiverOffset; - __ mov(receiver, FieldOperand(receiver, receiver_offset)); + const int proxy_offset = GlobalObject::kGlobalProxyOffset; + __ mov(receiver, FieldOperand(receiver, proxy_offset)); __ bind(&receiver_ok); } diff --git a/src/ia32/stub-cache-ia32.cc b/src/ia32/stub-cache-ia32.cc index bf4d04a..4b5d169 100644 --- a/src/ia32/stub-cache-ia32.cc +++ b/src/ia32/stub-cache-ia32.cc @@ -1177,7 +1177,7 @@ void StoreStubCompiler::GenerateStoreViaSetter( if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ mov(receiver, - FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ push(receiver); __ push(value()); @@ -1334,7 +1334,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ mov(receiver, - FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ push(receiver); ParameterCount actual(0); diff --git a/src/ic-inl.h b/src/ic-inl.h index 25094ae..a26d31b 100644 --- a/src/ic-inl.h +++ b/src/ic-inl.h @@ -153,7 +153,7 @@ Handle IC::GetCodeCacheHolder(InlineCacheHolderFlag flag, HeapType* type, Isolate* isolate) { if (flag == PROTOTYPE_MAP) { - Context* context = isolate->context()->native_context(); + Context* context = *isolate->native_context(); JSFunction* constructor; if (type->Is(HeapType::Boolean())) { constructor = context->boolean_function(); diff --git a/src/ic.cc b/src/ic.cc index 5a4135b..687960f 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -1852,7 +1852,7 @@ bool CallIC::DoCustomHandler(Handle receiver, // Are we the array function? Handle array_function = Handle( - isolate()->context()->native_context()->array_function(), isolate()); + isolate()->native_context()->array_function()); if (array_function.is_identical_to(Handle::cast(function))) { // Alter the slot. Handle new_site = isolate()->factory()->NewAllocationSite(); diff --git a/src/isolate.cc b/src/isolate.cc index 05f8792..1592667 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -1303,12 +1303,12 @@ void Isolate::SetCaptureStackTraceForUncaughtExceptions( Handle Isolate::native_context() { - return Handle(context()->global_object()->native_context()); + return handle(context()->native_context()); } Handle Isolate::global_context() { - return Handle(context()->global_object()->global_context()); + return handle(context()->global_object()->global_context()); } diff --git a/src/isolate.h b/src/isolate.h index 157839f..972a518 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -648,7 +648,7 @@ class Isolate { } // Returns the global proxy object of the current context. - Object* global_proxy() { + JSObject* global_proxy() { return context()->global_proxy(); } @@ -815,10 +815,10 @@ class Isolate { #define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \ Handle name() { \ - return Handle(context()->native_context()->name(), this); \ + return Handle(native_context()->name(), this); \ } \ bool is_##name(type* value) { \ - return context()->native_context()->is_##name(value); \ + return native_context()->is_##name(value); \ } NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) #undef NATIVE_CONTEXT_FIELD_ACCESSOR diff --git a/src/objects-inl.h b/src/objects-inl.h index 3a2fe93..bca5a55 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -5151,7 +5151,7 @@ ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset) ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset) ACCESSORS(GlobalObject, native_context, Context, kNativeContextOffset) ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset) -ACCESSORS(GlobalObject, global_receiver, JSObject, kGlobalReceiverOffset) +ACCESSORS(GlobalObject, global_proxy, JSObject, kGlobalProxyOffset) ACCESSORS(JSGlobalProxy, native_context, Object, kNativeContextOffset) ACCESSORS(JSGlobalProxy, hash, Object, kHashOffset) @@ -5739,6 +5739,11 @@ Context* JSFunction::context() { } +JSObject* JSFunction::global_proxy() { + return context()->global_proxy(); +} + + void JSFunction::set_context(Object* value) { ASSERT(value->IsUndefined() || value->IsContext()); WRITE_FIELD(this, kContextOffset, value); @@ -6481,7 +6486,7 @@ PropertyAttributes JSReceiver::GetElementAttribute(Handle object, bool JSGlobalObject::IsDetached() { - return JSGlobalProxy::cast(global_receiver())->IsDetachedFrom(this); + return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this); } diff --git a/src/objects.h b/src/objects.h index 764cdd9..526760a 100644 --- a/src/objects.h +++ b/src/objects.h @@ -7598,6 +7598,7 @@ class JSFunction: public JSObject { // [context]: The context for this function. inline Context* context(); inline void set_context(Object* context); + inline JSObject* global_proxy(); // [code]: The generated code object for this function. Executed // when the function is invoked, e.g. foo() or new foo(). See @@ -7851,8 +7852,8 @@ class GlobalObject: public JSObject { // [global context]: the most recent (i.e. innermost) global context. DECL_ACCESSORS(global_context, Context) - // [global receiver]: the global receiver object of the context - DECL_ACCESSORS(global_receiver, JSObject) + // [global proxy]: the global proxy object of the context + DECL_ACCESSORS(global_proxy, JSObject) // Retrieve the property cell used to store a property. PropertyCell* GetPropertyCell(LookupResult* result); @@ -7863,8 +7864,8 @@ class GlobalObject: public JSObject { static const int kBuiltinsOffset = JSObject::kHeaderSize; static const int kNativeContextOffset = kBuiltinsOffset + kPointerSize; static const int kGlobalContextOffset = kNativeContextOffset + kPointerSize; - static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; - static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; + static const int kGlobalProxyOffset = kGlobalContextOffset + kPointerSize; + static const int kHeaderSize = kGlobalProxyOffset + kPointerSize; private: DISALLOW_IMPLICIT_CONSTRUCTORS(GlobalObject); diff --git a/src/proxy.js b/src/proxy.js index 99f9dab..0776eea 100644 --- a/src/proxy.js +++ b/src/proxy.js @@ -49,8 +49,8 @@ function ProxyCreateFunction(handler, callTrap, constructTrap) { function SetUpProxy() { %CheckIsBootstrapping() - var global_receiver = %GlobalReceiver(global); - global_receiver.Proxy = $Proxy; + var global_proxy = %GlobalProxy(global); + global_proxy.Proxy = $Proxy; // Set up non-enumerable properties of the Proxy object. InstallFunctions($Proxy, DONT_ENUM, [ diff --git a/src/runtime.cc b/src/runtime.cc index 37e2fde..44f0916 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2116,8 +2116,7 @@ static Object* ThrowRedeclarationError(Isolate* isolate, Handle name) { RUNTIME_FUNCTION(Runtime_DeclareGlobals) { HandleScope scope(isolate); ASSERT(args.length() == 3); - Handle global = Handle( - isolate->context()->global_object()); + Handle global(isolate->global_object()); CONVERT_ARG_HANDLE_CHECKED(Context, context, 0); CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1); @@ -2739,9 +2738,7 @@ RUNTIME_FUNCTION(Runtime_GetDefaultReceiver) { // Returns undefined for strict or native functions, or // the associated global receiver for "normal" functions. - Context* native_context = - function->context()->global_object()->native_context(); - return native_context->global_object()->global_receiver(); + return function->global_proxy(); } @@ -8278,7 +8275,7 @@ static Object* Runtime_NewObjectHelper(Isolate* isolate, // instead of a new JSFunction object. This way, errors are // reported the same way whether or not 'Function' is called // using 'new'. - return isolate->context()->global_proxy(); + return isolate->global_proxy(); } } @@ -8952,7 +8949,7 @@ RUNTIME_FUNCTION(Runtime_PushWithContext) { // A smi sentinel indicates a context nested inside global code rather // than some function. There is a canonical empty function that can be // gotten from the native context. - function = handle(isolate->context()->native_context()->closure()); + function = handle(isolate->native_context()->closure()); } else { function = args.at(1); } @@ -8975,7 +8972,7 @@ RUNTIME_FUNCTION(Runtime_PushCatchContext) { // A smi sentinel indicates a context nested inside global code rather // than some function. There is a canonical empty function that can be // gotten from the native context. - function = handle(isolate->context()->native_context()->closure()); + function = handle(isolate->native_context()->closure()); } else { function = args.at(2); } @@ -8996,7 +8993,7 @@ RUNTIME_FUNCTION(Runtime_PushBlockContext) { // A smi sentinel indicates a context nested inside global code rather // than some function. There is a canonical empty function that can be // gotten from the native context. - function = handle(isolate->context()->native_context()->closure()); + function = handle(isolate->native_context()->closure()); } else { function = args.at(1); } @@ -9682,12 +9679,12 @@ RUNTIME_FUNCTION(Runtime_DateCacheVersion) { } -RUNTIME_FUNCTION(Runtime_GlobalReceiver) { +RUNTIME_FUNCTION(Runtime_GlobalProxy) { SealHandleScope shs(isolate); ASSERT(args.length() == 1); CONVERT_ARG_CHECKED(Object, global, 0); if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); - return JSGlobalObject::cast(global)->global_receiver(); + return JSGlobalObject::cast(global)->global_proxy(); } @@ -9794,7 +9791,7 @@ RUNTIME_FUNCTION(Runtime_CompileString) { CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1); // Extract native context. - Handle context(isolate->context()->native_context()); + Handle context(isolate->native_context()); // Filter cross security context calls. if (!TokensMatchForCompileString(isolate)) { @@ -11397,8 +11394,7 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) { // native context. it.Advance(); if (receiver->IsUndefined()) { - Context* context = function->context(); - receiver = handle(context->global_object()->global_receiver()); + receiver = handle(function->global_proxy()); } else { ASSERT(!receiver->IsNull()); Context* context = Context::cast(it.frame()->context()); @@ -12969,7 +12965,7 @@ RUNTIME_FUNCTION(Runtime_DebugEvaluateGlobal) { // Get the native context now set to the top context from before the // debugger was invoked. Handle context = isolate->native_context(); - Handle receiver = isolate->global_object(); + Handle receiver(context->global_proxy()); Handle result; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( isolate, result, @@ -13095,7 +13091,7 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { // Get the constructor function for context extension and arguments array. Handle arguments_boilerplate( - isolate->context()->native_context()->sloppy_arguments_boilerplate()); + isolate->sloppy_arguments_boilerplate()); Handle arguments_function( JSFunction::cast(arguments_boilerplate->map()->constructor())); @@ -13124,8 +13120,7 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) { } // Return result as JS array. - Handle constructor( - isolate->context()->native_context()->array_function()); + Handle constructor = isolate->array_function(); Handle result = isolate->factory()->NewJSObject(constructor); JSArray::SetContent(Handle::cast(result), instances); @@ -13207,8 +13202,7 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) { } // Return result as JS array. - Handle array_function( - isolate->context()->native_context()->array_function()); + Handle array_function = isolate->array_function(); Handle result = isolate->factory()->NewJSObject(array_function); JSArray::SetContent(Handle::cast(result), instances); return *result; @@ -13621,14 +13615,14 @@ RUNTIME_FUNCTION(Runtime_ExecuteInDebugContext) { if (without_debugger) { maybe_result = Execution::Call(isolate, function, - isolate->global_object(), + handle(function->global_proxy()), 0, NULL); } else { DebugScope debug_scope(isolate->debug()); maybe_result = Execution::Call(isolate, function, - isolate->global_object(), + handle(function->global_proxy()), 0, NULL); } @@ -14617,8 +14611,7 @@ RUNTIME_FUNCTION(Runtime_GetFromCache) { Handle factory(JSFunction::cast( cache_handle->get(JSFunctionResultCache::kFactoryIndex))); // TODO(antonm): consider passing a receiver when constructing a cache. - Handle receiver(isolate->native_context()->global_object(), - isolate); + Handle receiver(isolate->global_proxy()); // This handle is nor shared, nor used later, so it's safe. Handle argv[] = { key_handle }; ASSIGN_RETURN_FAILURE_ON_EXCEPTION( @@ -14869,8 +14862,7 @@ RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) { CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1); CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2); - Handle observer_context(observer->context()->native_context(), - isolate); + Handle observer_context(observer->context()->native_context()); Handle object_context(object->GetCreationContext()); Handle record_context(record->GetCreationContext()); diff --git a/src/runtime.h b/src/runtime.h index f4fe6f7..c220b93 100644 --- a/src/runtime.h +++ b/src/runtime.h @@ -221,7 +221,7 @@ namespace internal { F(CompileString, 2, 1) \ \ /* Eval */ \ - F(GlobalReceiver, 1, 1) \ + F(GlobalProxy, 1, 1) \ F(IsAttachedGlobal, 1, 1) \ \ F(AddProperty, 4, 1) \ diff --git a/src/v8natives.js b/src/v8natives.js index 4f12eec..5ffff2e 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -172,12 +172,12 @@ function GlobalEval(x) { 'be the global object from which eval originated'); } - var global_receiver = %GlobalReceiver(global); + var global_proxy = %GlobalProxy(global); var f = %CompileString(x, false); if (!IS_FUNCTION(f)) return f; - return %_CallFunction(global_receiver, f); + return %_CallFunction(global_proxy, f); } @@ -274,7 +274,7 @@ function ObjectPropertyIsEnumerable(V) { function ObjectDefineGetter(name, fun) { var receiver = this; if (receiver == null && !IS_UNDETECTABLE(receiver)) { - receiver = %GlobalReceiver(global); + receiver = %GlobalProxy(global); } if (!IS_SPEC_FUNCTION(fun)) { throw new $TypeError( @@ -291,7 +291,7 @@ function ObjectDefineGetter(name, fun) { function ObjectLookupGetter(name) { var receiver = this; if (receiver == null && !IS_UNDETECTABLE(receiver)) { - receiver = %GlobalReceiver(global); + receiver = %GlobalProxy(global); } return %LookupAccessor(ToObject(receiver), ToName(name), GETTER); } @@ -300,7 +300,7 @@ function ObjectLookupGetter(name) { function ObjectDefineSetter(name, fun) { var receiver = this; if (receiver == null && !IS_UNDETECTABLE(receiver)) { - receiver = %GlobalReceiver(global); + receiver = %GlobalProxy(global); } if (!IS_SPEC_FUNCTION(fun)) { throw new $TypeError( @@ -317,7 +317,7 @@ function ObjectDefineSetter(name, fun) { function ObjectLookupSetter(name) { var receiver = this; if (receiver == null && !IS_UNDETECTABLE(receiver)) { - receiver = %GlobalReceiver(global); + receiver = %GlobalProxy(global); } return %LookupAccessor(ToObject(receiver), ToName(name), SETTER); } @@ -1831,12 +1831,12 @@ function NewFunctionString(arguments, function_token) { function FunctionConstructor(arg1) { // length == 1 var source = NewFunctionString(arguments, 'function'); - var global_receiver = %GlobalReceiver(global); + var global_proxy = %GlobalProxy(global); // Compile the string in the constructor and not a helper so that errors // appear to come from here. var f = %CompileString(source, true); if (!IS_FUNCTION(f)) return f; - f = %_CallFunction(global_receiver, f); + f = %_CallFunction(global_proxy, f); %FunctionMarkNameShouldPrintAsAnonymous(f); return f; } diff --git a/src/x64/builtins-x64.cc b/src/x64/builtins-x64.cc index 2aea7b9..272c977 100644 --- a/src/x64/builtins-x64.cc +++ b/src/x64/builtins-x64.cc @@ -828,7 +828,7 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { // 3a. Patch the first argument if necessary when calling a function. Label shift_arguments; __ Set(rdx, 0); // indicate regular JS_FUNCTION - { Label convert_to_object, use_global_receiver, patch_receiver; + { Label convert_to_object, use_global_proxy, patch_receiver; // Change context eagerly in case we need the global receiver. __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); @@ -849,9 +849,9 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ JumpIfSmi(rbx, &convert_to_object, Label::kNear); __ CompareRoot(rbx, Heap::kNullValueRootIndex); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); STATIC_ASSERT(LAST_SPEC_OBJECT_TYPE == LAST_TYPE); __ CmpObjectType(rbx, FIRST_SPEC_OBJECT_TYPE, rcx); @@ -877,10 +877,10 @@ void Builtins::Generate_FunctionCall(MacroAssembler* masm) { __ movp(rdi, args.GetReceiverOperand()); __ jmp(&patch_receiver, Label::kNear); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ movp(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); - __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); + __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalProxyOffset)); __ bind(&patch_receiver); __ movp(args.GetArgumentOperand(1), rbx); @@ -1024,7 +1024,7 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ movp(rsi, FieldOperand(rdi, JSFunction::kContextOffset)); // Do not transform the receiver for strict mode functions. - Label call_to_object, use_global_receiver; + Label call_to_object, use_global_proxy; __ movp(rdx, FieldOperand(rdi, JSFunction::kSharedFunctionInfoOffset)); __ testb(FieldOperand(rdx, SharedFunctionInfo::kStrictModeByteOffset), Immediate(1 << SharedFunctionInfo::kStrictModeBitWithinByte)); @@ -1038,9 +1038,9 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { // Compute the receiver in sloppy mode. __ JumpIfSmi(rbx, &call_to_object, Label::kNear); __ CompareRoot(rbx, Heap::kNullValueRootIndex); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex); - __ j(equal, &use_global_receiver); + __ j(equal, &use_global_proxy); // If given receiver is already a JavaScript object then there's no // reason for converting it. @@ -1055,10 +1055,10 @@ void Builtins::Generate_FunctionApply(MacroAssembler* masm) { __ movp(rbx, rax); __ jmp(&push_receiver, Label::kNear); - __ bind(&use_global_receiver); + __ bind(&use_global_proxy); __ movp(rbx, Operand(rsi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); - __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalReceiverOffset)); + __ movp(rbx, FieldOperand(rbx, GlobalObject::kGlobalProxyOffset)); // Push the receiver. __ bind(&push_receiver); diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index a154107..54e68ae 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -123,7 +123,7 @@ void FullCodeGenerator::Generate() { __ j(not_equal, &ok, Label::kNear); __ movp(rcx, GlobalObjectOperand()); - __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); + __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset)); __ movp(args.GetReceiverOperand(), rcx); diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc index df3c589..b524e8a 100644 --- a/src/x64/lithium-codegen-x64.cc +++ b/src/x64/lithium-codegen-x64.cc @@ -137,7 +137,7 @@ bool LCodeGen::GeneratePrologue() { __ j(not_equal, &ok, Label::kNear); __ movp(rcx, GlobalObjectOperand()); - __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalReceiverOffset)); + __ movp(rcx, FieldOperand(rcx, GlobalObject::kGlobalProxyOffset)); __ movp(args.GetReceiverOperand(), rcx); @@ -3392,8 +3392,7 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) { __ movp(receiver, Operand(receiver, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); - __ movp(receiver, - FieldOperand(receiver, GlobalObject::kGlobalReceiverOffset)); + __ movp(receiver, FieldOperand(receiver, GlobalObject::kGlobalProxyOffset)); __ bind(&receiver_ok); } diff --git a/src/x64/stub-cache-x64.cc b/src/x64/stub-cache-x64.cc index 0298617..9e33423 100644 --- a/src/x64/stub-cache-x64.cc +++ b/src/x64/stub-cache-x64.cc @@ -1109,7 +1109,7 @@ void StoreStubCompiler::GenerateStoreViaSetter( if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ movp(receiver, - FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ Push(receiver); __ Push(value()); @@ -1278,7 +1278,7 @@ void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { // Swap in the global receiver. __ movp(receiver, - FieldOperand(receiver, JSGlobalObject::kGlobalReceiverOffset)); + FieldOperand(receiver, JSGlobalObject::kGlobalProxyOffset)); } __ Push(receiver); ParameterCount actual(0); diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index cd34d06..bef9897 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -1641,9 +1641,9 @@ TEST(GlobalObjectFields) { const v8::HeapGraphNode* global_context = GetProperty(global, v8::HeapGraphEdge::kInternal, "global_context"); CHECK_NE(NULL, global_context); - const v8::HeapGraphNode* global_receiver = - GetProperty(global, v8::HeapGraphEdge::kInternal, "global_receiver"); - CHECK_NE(NULL, global_receiver); + const v8::HeapGraphNode* global_proxy = + GetProperty(global, v8::HeapGraphEdge::kInternal, "global_proxy"); + CHECK_NE(NULL, global_proxy); } diff --git a/test/mjsunit/runtime-gen/globalreceiver.js b/test/mjsunit/runtime-gen/globalproxy.js similarity index 88% rename from test/mjsunit/runtime-gen/globalreceiver.js rename to test/mjsunit/runtime-gen/globalproxy.js index 332a334..52e160f 100644 --- a/test/mjsunit/runtime-gen/globalreceiver.js +++ b/test/mjsunit/runtime-gen/globalproxy.js @@ -2,4 +2,4 @@ // AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY // Flags: --allow-natives-syntax --harmony var _global = new Object(); -%GlobalReceiver(_global); +%GlobalProxy(_global); -- 2.7.4