Commit 55480ba3 authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [runtime] Replace global object link with native context link in all contexts.

  port 47502a23 (r32381)

  original commit message:
  Previously all contexts had a link to the global object, but what is
  required in most cases (except for the global load, store and delete
  case) is the native context.

  This also removes the second dummy global object that was still linked
  to every native context. We will add a different mechanism to ensure
  that builtins do not pollute the actual global object during
  bootstrapping.

  Drive-by-fix: Unify some MacroAssembler magic and drop obsolete stuff.

BUG=

Review URL: https://codereview.chromium.org/1481353002

Cr-Commit-Position: refs/heads/master@{#32387}
parent 2fee8a0f
......@@ -3459,10 +3459,8 @@ void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
__ jmp(&receiver_ok, Label::kNear);
__ bind(&global_object);
__ mov(receiver, FieldOperand(function, JSFunction::kContextOffset));
const int global_offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
__ mov(receiver, Operand(receiver, global_offset));
const int proxy_offset = JSGlobalObject::kGlobalProxyOffset;
__ mov(receiver, FieldOperand(receiver, proxy_offset));
__ mov(receiver, ContextOperand(receiver, Context::NATIVE_CONTEXT_INDEX));
__ mov(receiver, ContextOperand(receiver, Context::GLOBAL_PROXY_INDEX));
__ bind(&receiver_ok);
}
......
......@@ -1297,7 +1297,10 @@ void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy,
Variable* var = proxy->var();
DCHECK(var->IsUnallocatedOrGlobalSlot() ||
(var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL));
__ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand());
__ mov(LoadDescriptor::ReceiverRegister(), NativeContextOperand());
__ mov(LoadDescriptor::ReceiverRegister(),
ContextOperand(LoadDescriptor::ReceiverRegister(),
Context::EXTENSION_INDEX));
__ mov(LoadDescriptor::NameRegister(), var->name());
__ mov(LoadDescriptor::SlotRegister(),
Immediate(SmiFromSlot(proxy->VariableFeedbackSlot())));
......@@ -2088,8 +2091,7 @@ void FullCodeGenerator::EmitCreateIteratorResult(bool done) {
__ CallRuntime(Runtime::kAllocateInNewSpace, 1);
__ bind(&done_allocate);
__ mov(ebx, GlobalObjectOperand());
__ mov(ebx, FieldOperand(ebx, JSGlobalObject::kNativeContextOffset));
__ mov(ebx, NativeContextOperand());
__ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX));
__ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx);
__ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
......@@ -2411,7 +2413,10 @@ void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op,
if (var->IsUnallocated()) {
// Global var, const, or let.
__ mov(StoreDescriptor::NameRegister(), var->name());
__ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand());
__ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand());
__ mov(StoreDescriptor::ReceiverRegister(),
ContextOperand(StoreDescriptor::ReceiverRegister(),
Context::EXTENSION_INDEX));
EmitLoadStoreICSlot(slot);
CallStoreIC();
......@@ -4030,8 +4035,7 @@ void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) {
Label runtime, done;
__ Allocate(JSIteratorResult::kSize, eax, ecx, edx, &runtime, TAG_OBJECT);
__ mov(ebx, GlobalObjectOperand());
__ mov(ebx, FieldOperand(ebx, JSGlobalObject::kNativeContextOffset));
__ mov(ebx, NativeContextOperand());
__ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX));
__ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx);
__ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
......@@ -4055,9 +4059,7 @@ void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) {
// Push undefined as receiver.
__ push(Immediate(isolate()->factory()->undefined_value()));
__ mov(eax, GlobalObjectOperand());
__ mov(eax, FieldOperand(eax, JSGlobalObject::kNativeContextOffset));
__ mov(eax, ContextOperand(eax, expr->context_index()));
__ LoadGlobalFunction(expr->context_index(), eax);
}
......@@ -4146,7 +4148,8 @@ void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
bool is_this = var->HasThisName(isolate());
DCHECK(is_sloppy(language_mode()) || is_this);
if (var->IsUnallocatedOrGlobalSlot()) {
__ push(GlobalObjectOperand());
__ mov(eax, NativeContextOperand());
__ push(ContextOperand(eax, Context::EXTENSION_INDEX));
__ push(Immediate(var->name()));
__ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2);
context()->Plug(eax);
......@@ -4711,8 +4714,7 @@ void FullCodeGenerator::PushFunctionArgumentForContextAllocation() {
// Contexts nested in the native context have a canonical empty function
// as their closure, not the anonymous closure containing the global
// code.
__ mov(eax, GlobalObjectOperand());
__ mov(eax, FieldOperand(eax, JSGlobalObject::kNativeContextOffset));
__ mov(eax, NativeContextOperand());
__ push(ContextOperand(eax, Context::CLOSURE_INDEX));
} else if (closure_scope->is_eval_scope()) {
// Contexts nested inside eval code have the same closure as the context
......
......@@ -114,10 +114,7 @@ void PropertyHandlerCompiler::GenerateDictionaryNegativeLookup(
void NamedLoadHandlerCompiler::GenerateDirectLoadGlobalFunctionPrototype(
MacroAssembler* masm, int index, Register result, Label* miss) {
const int offset = Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX);
__ mov(result, Operand(esi, offset));
__ mov(result, FieldOperand(result, JSGlobalObject::kNativeContextOffset));
__ mov(result, Operand(result, Context::SlotOffset(index)));
__ LoadGlobalFunction(index, result);
// Load its initial map. The global functions all have initial maps.
__ mov(result,
FieldOperand(result, JSFunction::kPrototypeOrInitialMapOffset));
......
......@@ -1922,8 +1922,8 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
__ jmp(edx);
__ bind(&set_global_proxy);
__ mov(ecx, GlobalObjectOperand());
__ mov(ecx, FieldOperand(ecx, JSGlobalObject::kGlobalProxyOffset));
__ mov(ecx, NativeContextOperand());
__ mov(ecx, ContextOperand(ecx, Context::GLOBAL_PROXY_INDEX));
__ mov(receiver_operand, ecx);
__ jmp(&valid_receiver, Label::kNear);
......
......@@ -593,8 +593,7 @@ void ArgumentsAccessStub::GenerateNewSloppyFast(MacroAssembler* masm) {
// esp[8] = parameter count (tagged)
// Get the arguments map from the current native context into edi.
Label has_mapped_parameters, instantiate;
__ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
__ mov(edi, FieldOperand(edi, JSGlobalObject::kNativeContextOffset));
__ mov(edi, NativeContextOperand());
__ mov(ebx, Operand(esp, 0 * kPointerSize));
__ test(ebx, ebx);
__ j(not_zero, &has_mapped_parameters, Label::kNear);
......@@ -797,10 +796,8 @@ void ArgumentsAccessStub::GenerateNewStrict(MacroAssembler* masm) {
__ Allocate(eax, eax, ebx, no_reg, &runtime, TAG_OBJECT);
// Get the arguments map from the current native context.
__ mov(edi, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
__ mov(edi, FieldOperand(edi, JSGlobalObject::kNativeContextOffset));
const int offset = Context::SlotOffset(Context::STRICT_ARGUMENTS_MAP_INDEX);
__ mov(edi, Operand(edi, offset));
__ mov(edi, NativeContextOperand());
__ mov(edi, ContextOperand(edi, Context::STRICT_ARGUMENTS_MAP_INDEX));
__ mov(FieldOperand(eax, JSObject::kMapOffset), edi);
__ mov(FieldOperand(eax, JSObject::kPropertiesOffset),
......@@ -1895,11 +1892,10 @@ void CallICStub::Generate(MacroAssembler* masm) {
__ cmp(edi, ecx);
__ j(equal, &miss);
// Make sure the function belongs to the same native context (which implies
// the same global object).
// Make sure the function belongs to the same native context.
__ mov(ecx, FieldOperand(edi, JSFunction::kContextOffset));
__ mov(ecx, ContextOperand(ecx, Context::GLOBAL_OBJECT_INDEX));
__ cmp(ecx, GlobalObjectOperand());
__ mov(ecx, ContextOperand(ecx, Context::NATIVE_CONTEXT_INDEX));
__ cmp(ecx, NativeContextOperand());
__ j(not_equal, &miss);
// Update stats.
......
......@@ -1035,10 +1035,7 @@ void MacroAssembler::CheckAccessGlobalProxy(Register holder_reg,
Check(not_equal, kWeShouldNotHaveAnEmptyLexicalContext);
}
// Load the native context of the current context.
int offset =
Context::kHeaderSize + Context::GLOBAL_OBJECT_INDEX * kPointerSize;
mov(scratch1, FieldOperand(scratch1, offset));
mov(scratch1, FieldOperand(scratch1, JSGlobalObject::kNativeContextOffset));
mov(scratch1, ContextOperand(scratch1, Context::NATIVE_CONTEXT_INDEX));
// Check the context is a native context.
if (emit_debug_code()) {
......@@ -2095,8 +2092,7 @@ void MacroAssembler::InvokeBuiltin(int native_context_index, InvokeFlag flag,
void MacroAssembler::GetBuiltinFunction(Register target,
int native_context_index) {
// Load the JavaScript builtin function from the builtins object.
mov(target, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
mov(target, FieldOperand(target, JSGlobalObject::kNativeContextOffset));
mov(target, NativeContextOperand());
mov(target, ContextOperand(target, native_context_index));
}
......@@ -2128,8 +2124,8 @@ void MacroAssembler::LoadContext(Register dst, int context_chain_length) {
void MacroAssembler::LoadGlobalProxy(Register dst) {
mov(dst, GlobalObjectOperand());
mov(dst, FieldOperand(dst, JSGlobalObject::kGlobalProxyOffset));
mov(dst, NativeContextOperand());
mov(dst, ContextOperand(dst, Context::GLOBAL_PROXY_INDEX));
}
......@@ -2140,8 +2136,7 @@ void MacroAssembler::LoadTransitionedArrayMapConditional(
Register scratch,
Label* no_map_match) {
// Load the global or builtins object from the current context.
mov(scratch, Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
mov(scratch, FieldOperand(scratch, JSGlobalObject::kNativeContextOffset));
mov(scratch, NativeContextOperand());
// Check that the function's map is the same as the expected cached map.
mov(scratch, Operand(scratch,
......@@ -2160,13 +2155,10 @@ void MacroAssembler::LoadTransitionedArrayMapConditional(
void MacroAssembler::LoadGlobalFunction(int index, Register function) {
// Load the global or builtins object from the current context.
mov(function,
Operand(esi, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX)));
// Load the native context from the global or builtins object.
mov(function, FieldOperand(function, JSGlobalObject::kNativeContextOffset));
// Load the native context from the current context.
mov(function, NativeContextOperand());
// Load the function from the native context.
mov(function, Operand(function, Context::SlotOffset(index)));
mov(function, ContextOperand(function, index));
}
......
......@@ -949,8 +949,8 @@ inline Operand ContextOperand(Register context, Register index) {
return Operand(context, index, times_pointer_size, Context::SlotOffset(0));
}
inline Operand GlobalObjectOperand() {
return ContextOperand(esi, Context::GLOBAL_OBJECT_INDEX);
inline Operand NativeContextOperand() {
return ContextOperand(esi, Context::NATIVE_CONTEXT_INDEX);
}
#ifdef GENERATED_CODE_COVERAGE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment