Handle<Object> value) {
if (value->IsNumber() || !value->IsJSValue()) return value;
Handle<JSValue> wrapper = Handle<JSValue>::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);
}
i::HandleScope scope(isolate);
i::Handle<i::JSFunction> fun = i::Handle<i::JSFunction>::cast(obj);
EXCEPTION_PREAMBLE(isolate);
- i::Handle<i::Object> receiver(
- isolate->context()->global_proxy(), isolate);
+ i::Handle<i::Object> receiver(isolate->global_proxy(), isolate);
i::Handle<i::Object> result;
has_pending_exception = !i::Execution::Call(
isolate, fun, receiver, 0, NULL).ToHandle(&result);
i::Isolate* isolate,
v8::ExtensionConfiguration* extensions,
v8::Handle<ObjectTemplate> global_template,
- v8::Handle<Value> global_object) {
+ v8::Handle<Value> maybe_global_proxy) {
i::Handle<i::Context> env;
// Enter V8 via an ENTER_V8 scope.
}
}
+ i::Handle<i::Object> proxy = Utils::OpenHandle(*maybe_global_proxy, true);
+ i::MaybeHandle<i::JSGlobalProxy> maybe_proxy;
+ if (!proxy.is_null()) {
+ maybe_proxy = i::Handle<i::JSGlobalProxy>::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()) {
i::Handle<i::Object> 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);
i::Handle<i::Object> 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);
i::Handle<i::Object> 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();
i::Handle<i::Object> 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();
i::Handle<i::Object> 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);
i::Handle<i::Object> 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);
i::Handle<i::Object> 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);
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(this);
i::Context* context = isolate->context();
if (context == NULL) return Local<Context>();
- i::Context* native_context = context->global_object()->native_context();
+ i::Context* native_context = context->native_context();
if (native_context == NULL) return Local<Context>();
return Utils::ToLocal(i::Handle<i::Context>(native_context));
}
// 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));
__ 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);
__ 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));
// 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)));
__ 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
__ 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
__ b(ne, &ok);
__ ldr(r2, GlobalObjectOperand());
- __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset));
+ __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset));
__ str(r2, MemOperand(sp, receiver_offset));
__ b(ne, &ok);
__ ldr(r2, GlobalObjectOperand());
- __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalReceiverOffset));
+ __ ldr(r2, FieldMemOperand(r2, GlobalObject::kGlobalProxyOffset));
__ str(r2, MemOperand(sp, receiver_offset));
__ 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);
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);
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);
// 3a. Patch the first argument if necessary when calling a function.
Label shift_arguments;
__ Mov(call_type, static_cast<int>(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));
__ 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,
__ Mov(call_type, static_cast<int>(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);
// 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.
// 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);
__ 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);
__ 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);
__ 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);
__ 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);
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);
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);
class Genesis BASE_EMBEDDED {
public:
Genesis(Isolate* isolate,
- Handle<Object> global_object,
- v8::Handle<v8::ObjectTemplate> global_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ v8::Handle<v8::ObjectTemplate> global_proxy_template,
v8::ExtensionConfiguration* extensions);
~Genesis() { }
// we have to used the deserialized ones that are linked together with the
// rest of the context snapshot.
Handle<JSGlobalProxy> CreateNewGlobals(
- v8::Handle<v8::ObjectTemplate> global_template,
- Handle<Object> global_object,
- Handle<GlobalObject>* global_proxy_out);
+ v8::Handle<v8::ObjectTemplate> global_proxy_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ Handle<GlobalObject>* 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<GlobalObject> inner_global,
+ void HookUpGlobalProxy(Handle<GlobalObject> global_object,
Handle<JSGlobalProxy> 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<GlobalObject> 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<GlobalObject> global_object);
// New context initialization. Used for creating a context from scratch.
- void InitializeGlobal(Handle<GlobalObject> inner_global,
+ void InitializeGlobal(Handle<GlobalObject> global_object,
Handle<JSFunction> empty_function);
void InitializeExperimentalGlobal();
// Installs the contents of the native .js files on the global objects.
bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
bool ConfigureApiObject(Handle<JSObject> object,
Handle<ObjectTemplateInfo> object_template);
- bool ConfigureGlobalObjects(v8::Handle<v8::ObjectTemplate> global_template);
+ bool ConfigureGlobalObjects(
+ v8::Handle<v8::ObjectTemplate> global_proxy_template);
// Migrates all properties from the 'from' object to the 'to'
// object and overrides the prototype in 'to' with the one from
Handle<Context> Bootstrapper::CreateEnvironment(
- Handle<Object> global_object,
- v8::Handle<v8::ObjectTemplate> global_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ v8::Handle<v8::ObjectTemplate> 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<Context> env = genesis.result();
if (env.is_null() || !InstallExtensions(env, extensions)) {
return Handle<Context>();
Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
- v8::Handle<v8::ObjectTemplate> global_template,
- Handle<Object> global_object,
- Handle<GlobalObject>* inner_global_out) {
- // The argument global_template aka data is an ObjectTemplateInfo.
+ v8::Handle<v8::ObjectTemplate> global_proxy_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ Handle<GlobalObject>* 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<JSFunction> js_global_function;
- Handle<ObjectTemplateInfo> js_global_template;
- if (!global_template.IsEmpty()) {
- // Get prototype template of the global_template.
+ // Step 1: Create a fresh JSGlobalObject.
+ Handle<JSFunction> js_global_object_function;
+ Handle<ObjectTemplateInfo> js_global_object_template;
+ if (!global_proxy_template.IsEmpty()) {
+ // Get prototype template of the global_proxy_template.
Handle<ObjectTemplateInfo> data =
- v8::Utils::OpenHandle(*global_template);
+ v8::Utils::OpenHandle(*global_proxy_template);
Handle<FunctionTemplateInfo> global_constructor =
Handle<FunctionTemplateInfo>(
FunctionTemplateInfo::cast(data->constructor()));
Handle<Object> proto_template(global_constructor->prototype_template(),
isolate());
if (!proto_template->IsUndefined()) {
- js_global_template =
+ js_global_object_template =
Handle<ObjectTemplateInfo>::cast(proto_template);
}
}
- if (js_global_template.is_null()) {
+ if (js_global_object_template.is_null()) {
Handle<String> name = Handle<String>(heap()->empty_string());
Handle<Code> code = Handle<Code>(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<JSObject> prototype =
Handle<JSObject>(
- 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<FunctionTemplateInfo> js_global_constructor(
- FunctionTemplateInfo::cast(js_global_template->constructor()));
- js_global_function =
- factory()->CreateApiFunction(js_global_constructor,
+ Handle<FunctionTemplateInfo> 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<GlobalObject> 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<GlobalObject> 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<JSFunction> global_proxy_function;
- if (global_template.IsEmpty()) {
+ if (global_proxy_template.IsEmpty()) {
Handle<String> name = Handle<String>(heap()->empty_string());
Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
Builtins::kIllegal));
name, code, JS_GLOBAL_PROXY_TYPE, JSGlobalProxy::kSize);
} else {
Handle<ObjectTemplateInfo> data =
- v8::Utils::OpenHandle(*global_template);
+ v8::Utils::OpenHandle(*global_proxy_template);
Handle<FunctionTemplateInfo> global_constructor(
FunctionTemplateInfo::cast(data->constructor()));
global_proxy_function =
factory()->CreateApiFunction(global_constructor,
factory()->the_hole_value(),
- factory()->OuterGlobalObject);
+ factory()->GlobalProxyType);
}
Handle<String> global_name = factory()->InternalizeOneByteString(
// Return the global proxy.
Handle<JSGlobalProxy> global_proxy;
- if (global_object.location() != NULL) {
- ASSERT(global_object->IsJSGlobalProxy());
- global_proxy = Handle<JSGlobalProxy>::cast(global_object);
+ if (maybe_global_proxy.ToHandle(&global_proxy)) {
factory()->ReinitializeJSGlobalProxy(global_proxy, global_proxy_function);
} else {
global_proxy = Handle<JSGlobalProxy>::cast(
}
-void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
+void Genesis::HookUpGlobalProxy(Handle<GlobalObject> global_object,
Handle<JSGlobalProxy> 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<GlobalObject> inner_global) {
- Handle<GlobalObject> inner_global_from_snapshot(
+void Genesis::HookUpGlobalObject(Handle<GlobalObject> global_object) {
+ Handle<GlobalObject> global_object_from_snapshot(
GlobalObject::cast(native_context()->extension()));
Handle<JSBuiltinsObject> 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<PropertyAttributes>(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<GlobalObject> inner_global,
+// work in the snapshot case is done in HookUpGlobalObject.
+void Genesis::InitializeGlobal(Handle<GlobalObject> global_object,
Handle<JSFunction> 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<String> 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<JSObject> global(native_context()->global_object());
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
{ Handle<String> key = factory()->function_class_string();
Handle<JSFunction> function =
Handle<JSFunction>::cast(Object::GetProperty(
- isolate()->global_object(), key).ToHandleChecked());
+ handle(native_context()->global_object()), key).ToHandleChecked());
Handle<JSObject> proto =
Handle<JSObject>(JSObject::cast(function->instance_prototype()));
v8::Handle<v8::ObjectTemplate> global_proxy_template) {
Handle<JSObject> global_proxy(
JSObject::cast(native_context()->global_proxy()));
- Handle<JSObject> inner_global(
+ Handle<JSObject> global_object(
JSObject::cast(native_context()->global_object()));
if (!global_proxy_template.IsEmpty()) {
// Configure the global proxy object.
- Handle<ObjectTemplateInfo> proxy_data =
+ Handle<ObjectTemplateInfo> 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<FunctionTemplateInfo> proxy_constructor(
- FunctionTemplateInfo::cast(proxy_data->constructor()));
+ FunctionTemplateInfo::cast(global_proxy_data->constructor()));
if (!proxy_constructor->prototype_template()->IsUndefined()) {
- Handle<ObjectTemplateInfo> inner_data(
+ Handle<ObjectTemplateInfo> 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()));
bool Genesis::ConfigureApiObject(Handle<JSObject> object,
- Handle<ObjectTemplateInfo> object_template) {
+ Handle<ObjectTemplateInfo> object_template) {
ASSERT(!object_template.is_null());
ASSERT(FunctionTemplateInfo::cast(object_template->constructor())
->IsTemplateFor(object->map()));;
Genesis::Genesis(Isolate* isolate,
- Handle<Object> global_object,
- v8::Handle<v8::ObjectTemplate> global_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ v8::Handle<v8::ObjectTemplate> global_proxy_template,
v8::ExtensionConfiguration* extensions)
: isolate_(isolate),
active_(isolate->bootstrapper()) {
AddToWeakNativeContextList(*native_context());
isolate->set_context(*native_context());
isolate->counters()->contexts_created_by_snapshot()->Increment();
- Handle<GlobalObject> inner_global;
- Handle<JSGlobalProxy> global_proxy =
- CreateNewGlobals(global_template,
- global_object,
- &inner_global);
-
- HookUpGlobalProxy(inner_global, global_proxy);
- HookUpInnerGlobal(inner_global);
- native_context()->builtins()->set_global_receiver(
+ Handle<GlobalObject> global_object;
+ Handle<JSGlobalProxy> 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<JSFunction> empty_function = CreateEmptyFunction(isolate);
CreateStrictModeFunctionMaps(empty_function);
- Handle<GlobalObject> inner_global;
- Handle<JSGlobalProxy> global_proxy =
- CreateNewGlobals(global_template, global_object, &inner_global);
- HookUpGlobalProxy(inner_global, global_proxy);
- InitializeGlobal(inner_global, empty_function);
+ Handle<GlobalObject> global_object;
+ Handle<JSGlobalProxy> 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();
}
// Creates a JavaScript Global Context with initial object graph.
// The returned value is a global handle casted to V8Environment*.
Handle<Context> CreateEnvironment(
- Handle<Object> global_object,
- v8::Handle<v8::ObjectTemplate> global_template,
+ MaybeHandle<JSGlobalProxy> maybe_global_proxy,
+ v8::Handle<v8::ObjectTemplate> global_object_template,
v8::ExtensionConfiguration* extensions);
// Detach the environment from its outer global object.
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);
Handle<Object> exception;
MaybeHandle<Object> result =
Execution::TryCall(function,
- Handle<Object>(context->global_object(), isolate),
+ handle(context->global_proxy()),
0,
NULL,
&exception);
ExtensionConfiguration no_extensions;
Handle<Context> context =
isolate_->bootstrapper()->CreateEnvironment(
- Handle<Object>::null(),
+ MaybeHandle<JSGlobalProxy>(),
v8::Handle<ObjectTemplate>(),
&no_extensions);
HandleScope scope(isolate_);
AssertDebugContext();
Factory* factory = isolate_->factory();
- JSObject::SetProperty(isolate_->global_object(),
+ Handle<GlobalObject> 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,
Handle<Object> argv[]) {
AssertDebugContext();
// Create the execution state object.
+ Handle<GlobalObject> global(isolate_->global_object());
Handle<Object> constructor = Object::GetProperty(
- isolate_, isolate_->global_object(), constructor_name).ToHandleChecked();
+ isolate_, global, constructor_name).ToHandleChecked();
ASSERT(constructor->IsJSFunction());
if (!constructor->IsJSFunction()) return MaybeHandle<Object>();
// We do not handle interrupts here. In particular, termination interrupts.
PostponeInterruptsScope no_interrupts(isolate_);
return Execution::TryCall(Handle<JSFunction>::cast(constructor),
- Handle<JSObject>(debug_context()->global_object()),
+ handle(debug_context()->global_proxy()),
argc,
argv);
}
exec_state,
event_data,
event_listener_data_ };
+ Handle<JSReceiver> global(isolate_->global_proxy());
Execution::TryCall(Handle<JSFunction>::cast(event_listener_),
- isolate_->global_object(),
- ARRAY_SIZE(argv),
- argv);
+ global, ARRAY_SIZE(argv), argv);
}
}
// receiver instead to avoid having a 'this' pointer which refers
// directly to a global object.
if (receiver->IsGlobalObject()) {
- Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
- receiver = Handle<JSObject>(global->global_receiver());
+ receiver = handle(Handle<GlobalObject>::cast(receiver)->global_proxy());
}
// Make sure that the global object of the context we're about to
!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<Object>(global, func->GetIsolate());
- }
+ receiver = handle(func->global_proxy());
+ ASSERT(!receiver->IsJSBuiltinsObject());
} else {
ASSIGN_RETURN_ON_EXCEPTION(
isolate, receiver, ToObject(isolate, receiver), Object);
MaybeHandle<Object> Execution::New(Handle<JSFunction> func,
int argc,
Handle<Object> argv[]) {
- return Invoke(true, func, func->GetIsolate()->global_object(), argc, argv);
+ return Invoke(true, func, handle(func->global_proxy()), argc, argv);
}
Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
Handle<String> name,
MaybeHandle<Code> code) {
- Handle<Context> context(isolate()->context()->native_context());
+ Handle<Context> context(isolate()->native_context());
Handle<SharedFunctionInfo> info = NewSharedFunctionInfo(name, code);
ASSERT((info->strict_mode() == SLOPPY) &&
(map.is_identical_to(isolate()->sloppy_function_map()) ||
Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
Handle<JSFunction> 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),
Handle<JSDataView> Factory::NewJSDataView() {
Handle<JSFunction> 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),
if (type == JS_FUNCTION_TYPE) {
map->set_function_with_prototype(true);
Handle<JSFunction> js_function = Handle<JSFunction>::cast(object);
- Handle<Context> context(isolate()->context()->native_context());
+ Handle<Context> context(isolate()->native_context());
InitializeFunction(js_function, shared.ToHandleChecked(), context);
}
}
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;
}
enum ApiInstanceType {
- JavaScriptObject,
- InnerGlobalObject,
- OuterGlobalObject
+ JavaScriptObjectType,
+ GlobalObjectType,
+ GlobalProxyType
};
Handle<JSFunction> CreateApiFunction(
Handle<FunctionTemplateInfo> data,
Handle<Object> prototype,
- ApiInstanceType type = JavaScriptObject);
+ ApiInstanceType type = JavaScriptObjectType);
Handle<JSFunction> InstallMembers(Handle<JSFunction> function);
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;
}
"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()) {
// 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;
// Cannot embed a direct reference to the global proxy
// as is it dropped on deserialization.
CHECK(!isolate()->serializer_enabled());
- Handle<JSObject> global_receiver(
- target->context()->global_object()->global_receiver());
- return Add<HConstant>(global_receiver);
+ Handle<JSObject> global_proxy(target->context()->global_proxy());
+ return Add<HConstant>(global_proxy);
}
return graph()->GetConstantUndefined();
}
// 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));
// 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);
__ 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);
__ 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);
// 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);
__ 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);
__ 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);
__ 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);
__ 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);
}
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());
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);
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();
// Are we the array function?
Handle<JSFunction> array_function = Handle<JSFunction>(
- isolate()->context()->native_context()->array_function(), isolate());
+ isolate()->native_context()->array_function());
if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) {
// Alter the slot.
Handle<AllocationSite> new_site = isolate()->factory()->NewAllocationSite();
Handle<Context> Isolate::native_context() {
- return Handle<Context>(context()->global_object()->native_context());
+ return handle(context()->native_context());
}
Handle<Context> Isolate::global_context() {
- return Handle<Context>(context()->global_object()->global_context());
+ return handle(context()->global_object()->global_context());
}
}
// Returns the global proxy object of the current context.
- Object* global_proxy() {
+ JSObject* global_proxy() {
return context()->global_proxy();
}
#define NATIVE_CONTEXT_FIELD_ACCESSOR(index, type, name) \
Handle<type> name() { \
- return Handle<type>(context()->native_context()->name(), this); \
+ return Handle<type>(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
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)
}
+JSObject* JSFunction::global_proxy() {
+ return context()->global_proxy();
+}
+
+
void JSFunction::set_context(Object* value) {
ASSERT(value->IsUndefined() || value->IsContext());
WRITE_FIELD(this, kContextOffset, value);
bool JSGlobalObject::IsDetached() {
- return JSGlobalProxy::cast(global_receiver())->IsDetachedFrom(this);
+ return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this);
}
// [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
// [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);
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);
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, [
RUNTIME_FUNCTION(Runtime_DeclareGlobals) {
HandleScope scope(isolate);
ASSERT(args.length() == 3);
- Handle<GlobalObject> global = Handle<GlobalObject>(
- isolate->context()->global_object());
+ Handle<GlobalObject> global(isolate->global_object());
CONVERT_ARG_HANDLE_CHECKED(Context, context, 0);
CONVERT_ARG_HANDLE_CHECKED(FixedArray, pairs, 1);
// 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();
}
// 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();
}
}
// 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<JSFunction>(1);
}
// 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<JSFunction>(2);
}
// 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<JSFunction>(1);
}
}
-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();
}
CONVERT_BOOLEAN_ARG_CHECKED(function_literal_only, 1);
// Extract native context.
- Handle<Context> context(isolate->context()->native_context());
+ Handle<Context> context(isolate->native_context());
// Filter cross security context calls.
if (!TokensMatchForCompileString(isolate)) {
// 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());
// Get the native context now set to the top context from before the
// debugger was invoked.
Handle<Context> context = isolate->native_context();
- Handle<Object> receiver = isolate->global_object();
+ Handle<JSObject> receiver(context->global_proxy());
Handle<Object> result;
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
isolate, result,
// Get the constructor function for context extension and arguments array.
Handle<JSObject> arguments_boilerplate(
- isolate->context()->native_context()->sloppy_arguments_boilerplate());
+ isolate->sloppy_arguments_boilerplate());
Handle<JSFunction> arguments_function(
JSFunction::cast(arguments_boilerplate->map()->constructor()));
}
// Return result as JS array.
- Handle<JSFunction> constructor(
- isolate->context()->native_context()->array_function());
+ Handle<JSFunction> constructor = isolate->array_function();
Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
JSArray::SetContent(Handle<JSArray>::cast(result), instances);
}
// Return result as JS array.
- Handle<JSFunction> array_function(
- isolate->context()->native_context()->array_function());
+ Handle<JSFunction> array_function = isolate->array_function();
Handle<JSObject> result = isolate->factory()->NewJSObject(array_function);
JSArray::SetContent(Handle<JSArray>::cast(result), instances);
return *result;
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);
}
Handle<JSFunction> factory(JSFunction::cast(
cache_handle->get(JSFunctionResultCache::kFactoryIndex)));
// TODO(antonm): consider passing a receiver when constructing a cache.
- Handle<Object> receiver(isolate->native_context()->global_object(),
- isolate);
+ Handle<JSObject> receiver(isolate->global_proxy());
// This handle is nor shared, nor used later, so it's safe.
Handle<Object> argv[] = { key_handle };
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
CONVERT_ARG_HANDLE_CHECKED(JSObject, object, 1);
CONVERT_ARG_HANDLE_CHECKED(JSObject, record, 2);
- Handle<Context> observer_context(observer->context()->native_context(),
- isolate);
+ Handle<Context> observer_context(observer->context()->native_context());
Handle<Context> object_context(object->GetCreationContext());
Handle<Context> record_context(record->GetCreationContext());
F(CompileString, 2, 1) \
\
/* Eval */ \
- F(GlobalReceiver, 1, 1) \
+ F(GlobalProxy, 1, 1) \
F(IsAttachedGlobal, 1, 1) \
\
F(AddProperty, 4, 1) \
'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);
}
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(
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);
}
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(
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);
}
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;
}
// 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));
__ 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);
__ 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);
__ 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));
// 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.
__ 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);
__ 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);
__ 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);
__ 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);
}
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());
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);
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);
}
// AUTO-GENERATED BY tools/generate-runtime-tests.py, DO NOT MODIFY
// Flags: --allow-natives-syntax --harmony
var _global = new Object();
-%GlobalReceiver(_global);
+%GlobalProxy(_global);