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
This commit is contained in:
parent
4e4fb07c24
commit
26eae0c429
@ -153,10 +153,9 @@ Handle<Object> Accessors::FlattenNumber(Isolate* isolate,
|
||||
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);
|
||||
}
|
||||
|
||||
|
37
src/api.cc
37
src/api.cc
@ -1647,8 +1647,7 @@ Local<Value> Script::Run() {
|
||||
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);
|
||||
@ -5105,7 +5104,7 @@ static i::Handle<i::Context> CreateEnvironment(
|
||||
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.
|
||||
@ -5143,11 +5142,14 @@ static i::Handle<i::Context> CreateEnvironment(
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
@ -5826,8 +5828,7 @@ bool Value::IsPromise() const {
|
||||
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);
|
||||
@ -5844,8 +5845,7 @@ Local<Promise::Resolver> Promise::Resolver::New(Isolate* v8_isolate) {
|
||||
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);
|
||||
@ -5869,8 +5869,7 @@ void Promise::Resolver::Resolve(Handle<Value> value) {
|
||||
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();
|
||||
@ -5887,8 +5886,7 @@ void Promise::Resolver::Reject(Handle<Value> value) {
|
||||
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();
|
||||
@ -5906,8 +5904,7 @@ Local<Promise> Promise::Chain(Handle<Function> handler) {
|
||||
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);
|
||||
@ -5926,8 +5923,7 @@ Local<Promise> Promise::Catch(Handle<Function> handler) {
|
||||
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);
|
||||
@ -5946,8 +5942,7 @@ Local<Promise> Promise::Then(Handle<Function> handler) {
|
||||
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);
|
||||
@ -6382,7 +6377,7 @@ v8::Local<v8::Context> Isolate::GetCurrentContext() {
|
||||
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));
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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));
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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<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));
|
||||
|
||||
@ -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<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);
|
||||
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -148,8 +148,8 @@ void Bootstrapper::TearDown() {
|
||||
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() { }
|
||||
|
||||
@ -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<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.
|
||||
@ -253,7 +253,8 @@ class Genesis BASE_EMBEDDED {
|
||||
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
|
||||
@ -327,11 +328,12 @@ void Bootstrapper::Iterate(ObjectVisitor* v) {
|
||||
|
||||
|
||||
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>();
|
||||
@ -729,73 +731,74 @@ void Genesis::CreateRoots() {
|
||||
|
||||
|
||||
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));
|
||||
@ -803,13 +806,13 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
||||
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(
|
||||
@ -821,9 +824,7 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
||||
// 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(
|
||||
@ -834,62 +835,61 @@ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
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 = inner_global->GetIsolate();
|
||||
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());
|
||||
|
||||
@ -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<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()));
|
||||
|
||||
@ -2386,26 +2385,26 @@ bool Genesis::ConfigureGlobalObjects(
|
||||
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()));
|
||||
@ -2415,7 +2414,7 @@ bool Genesis::ConfigureGlobalObjects(
|
||||
|
||||
|
||||
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()));;
|
||||
@ -2573,8 +2572,8 @@ class NoTrackDoubleFieldsForSerializerScope {
|
||||
|
||||
|
||||
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()) {
|
||||
@ -2605,35 +2604,33 @@ Genesis::Genesis(Isolate* isolate,
|
||||
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);
|
||||
Handle<GlobalObject> global_object;
|
||||
Handle<JSGlobalProxy> global_proxy = CreateNewGlobals(
|
||||
global_proxy_template, maybe_global_proxy, &global_object);
|
||||
|
||||
HookUpGlobalProxy(inner_global, global_proxy);
|
||||
HookUpInnerGlobal(inner_global);
|
||||
native_context()->builtins()->set_global_receiver(
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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<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.
|
||||
|
@ -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);
|
||||
|
19
src/debug.cc
19
src/debug.cc
@ -759,7 +759,7 @@ bool Debug::CompileDebuggerScript(Isolate* isolate, int index) {
|
||||
Handle<Object> exception;
|
||||
MaybeHandle<Object> result =
|
||||
Execution::TryCall(function,
|
||||
Handle<Object>(context->global_object(), isolate),
|
||||
handle(context->global_proxy()),
|
||||
0,
|
||||
NULL,
|
||||
&exception);
|
||||
@ -807,7 +807,7 @@ bool Debug::Load() {
|
||||
ExtensionConfiguration no_extensions;
|
||||
Handle<Context> context =
|
||||
isolate_->bootstrapper()->CreateEnvironment(
|
||||
Handle<Object>::null(),
|
||||
MaybeHandle<JSGlobalProxy>(),
|
||||
v8::Handle<ObjectTemplate>(),
|
||||
&no_extensions);
|
||||
|
||||
@ -2446,12 +2446,13 @@ void Debug::ClearMirrorCache() {
|
||||
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,
|
||||
@ -2494,14 +2495,15 @@ MaybeHandle<Object> Debug::MakeJSObject(const char* constructor_name,
|
||||
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);
|
||||
}
|
||||
@ -2777,10 +2779,9 @@ void Debug::CallEventCallback(v8::DebugEvent event,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,8 +70,7 @@ MUST_USE_RESULT static MaybeHandle<Object> Invoke(
|
||||
// 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
|
||||
@ -133,13 +132,8 @@ MaybeHandle<Object> 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<Object>(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<Object> Execution::Call(Isolate* isolate,
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1244,7 +1244,7 @@ Handle<JSFunction> Factory::NewFunction(Handle<Map> map,
|
||||
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()) ||
|
||||
@ -1687,7 +1687,7 @@ Handle<JSGeneratorObject> Factory::NewJSGeneratorObject(
|
||||
|
||||
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),
|
||||
@ -1697,7 +1697,7 @@ Handle<JSArrayBuffer> Factory::NewJSArrayBuffer() {
|
||||
|
||||
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),
|
||||
@ -1821,7 +1821,7 @@ void Factory::ReinitializeJSReceiver(Handle<JSReceiver> object,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -2117,15 +2117,15 @@ Handle<JSFunction> 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;
|
||||
|
@ -559,15 +559,15 @@ class Factory V8_FINAL {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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()) {
|
||||
|
@ -8441,9 +8441,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> 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<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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -153,7 +153,7 @@ Handle<Map> 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();
|
||||
|
@ -1852,7 +1852,7 @@ bool CallIC::DoCustomHandler(Handle<Object> receiver,
|
||||
|
||||
// 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();
|
||||
|
@ -1303,12 +1303,12 @@ void Isolate::SetCaptureStackTraceForUncaughtExceptions(
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
|
||||
|
@ -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<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
|
||||
|
@ -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<JSReceiver> object,
|
||||
|
||||
|
||||
bool JSGlobalObject::IsDetached() {
|
||||
return JSGlobalProxy::cast(global_receiver())->IsDetachedFrom(this);
|
||||
return JSGlobalProxy::cast(global_proxy())->IsDetachedFrom(this);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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, [
|
||||
|
@ -2116,8 +2116,7 @@ static Object* ThrowRedeclarationError(Isolate* isolate, Handle<String> name) {
|
||||
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);
|
||||
@ -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<JSFunction>(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<JSFunction>(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<JSFunction>(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> context(isolate->context()->native_context());
|
||||
Handle<Context> 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> 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,
|
||||
@ -13095,7 +13091,7 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
|
||||
|
||||
// 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()));
|
||||
|
||||
@ -13124,8 +13120,7 @@ RUNTIME_FUNCTION(Runtime_DebugReferencedBy) {
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -13207,8 +13202,7 @@ RUNTIME_FUNCTION(Runtime_DebugConstructedBy) {
|
||||
}
|
||||
|
||||
// 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;
|
||||
@ -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<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(
|
||||
@ -14869,8 +14862,7 @@ RUNTIME_FUNCTION(Runtime_ObserverObjectAndRecordHaveSameOrigin) {
|
||||
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());
|
||||
|
||||
|
@ -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) \
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -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);
|
Loading…
Reference in New Issue
Block a user