OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 __ jmp(done); | 1298 __ jmp(done); |
1299 } | 1299 } |
1300 } | 1300 } |
1301 | 1301 |
1302 | 1302 |
1303 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, | 1303 void FullCodeGenerator::EmitGlobalVariableLoad(VariableProxy* proxy, |
1304 TypeofMode typeof_mode) { | 1304 TypeofMode typeof_mode) { |
1305 Variable* var = proxy->var(); | 1305 Variable* var = proxy->var(); |
1306 DCHECK(var->IsUnallocatedOrGlobalSlot() || | 1306 DCHECK(var->IsUnallocatedOrGlobalSlot() || |
1307 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); | 1307 (var->IsLookupSlot() && var->mode() == DYNAMIC_GLOBAL)); |
1308 __ mov(LoadDescriptor::ReceiverRegister(), NativeContextOperand()); | 1308 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1309 __ mov(LoadDescriptor::ReceiverRegister(), | |
1310 ContextOperand(LoadDescriptor::ReceiverRegister(), | |
1311 Context::EXTENSION_INDEX)); | |
1312 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1309 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1313 __ mov(LoadDescriptor::SlotRegister(), | 1310 __ mov(LoadDescriptor::SlotRegister(), |
1314 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1311 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1315 CallLoadIC(typeof_mode); | 1312 CallLoadIC(typeof_mode); |
1316 } | 1313 } |
1317 | 1314 |
1318 | 1315 |
1319 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, | 1316 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy, |
1320 TypeofMode typeof_mode) { | 1317 TypeofMode typeof_mode) { |
1321 SetExpressionPosition(proxy); | 1318 SetExpressionPosition(proxy); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 Label allocate, done_allocate; | 2089 Label allocate, done_allocate; |
2093 | 2090 |
2094 __ Allocate(JSIteratorResult::kSize, eax, ecx, edx, &allocate, TAG_OBJECT); | 2091 __ Allocate(JSIteratorResult::kSize, eax, ecx, edx, &allocate, TAG_OBJECT); |
2095 __ jmp(&done_allocate, Label::kNear); | 2092 __ jmp(&done_allocate, Label::kNear); |
2096 | 2093 |
2097 __ bind(&allocate); | 2094 __ bind(&allocate); |
2098 __ Push(Smi::FromInt(JSIteratorResult::kSize)); | 2095 __ Push(Smi::FromInt(JSIteratorResult::kSize)); |
2099 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); | 2096 __ CallRuntime(Runtime::kAllocateInNewSpace, 1); |
2100 | 2097 |
2101 __ bind(&done_allocate); | 2098 __ bind(&done_allocate); |
2102 __ mov(ebx, NativeContextOperand()); | 2099 __ mov(ebx, GlobalObjectOperand()); |
| 2100 __ mov(ebx, FieldOperand(ebx, JSGlobalObject::kNativeContextOffset)); |
2103 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX)); | 2101 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX)); |
2104 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); | 2102 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); |
2105 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), | 2103 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |
2106 isolate()->factory()->empty_fixed_array()); | 2104 isolate()->factory()->empty_fixed_array()); |
2107 __ mov(FieldOperand(eax, JSObject::kElementsOffset), | 2105 __ mov(FieldOperand(eax, JSObject::kElementsOffset), |
2108 isolate()->factory()->empty_fixed_array()); | 2106 isolate()->factory()->empty_fixed_array()); |
2109 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset)); | 2107 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset)); |
2110 __ mov(FieldOperand(eax, JSIteratorResult::kDoneOffset), | 2108 __ mov(FieldOperand(eax, JSIteratorResult::kDoneOffset), |
2111 isolate()->factory()->ToBoolean(done)); | 2109 isolate()->factory()->ToBoolean(done)); |
2112 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); | 2110 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2414 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); | 2412 __ RecordWriteContextSlot(ecx, offset, edx, ebx, kDontSaveFPRegs); |
2415 } | 2413 } |
2416 } | 2414 } |
2417 | 2415 |
2418 | 2416 |
2419 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, | 2417 void FullCodeGenerator::EmitVariableAssignment(Variable* var, Token::Value op, |
2420 FeedbackVectorSlot slot) { | 2418 FeedbackVectorSlot slot) { |
2421 if (var->IsUnallocated()) { | 2419 if (var->IsUnallocated()) { |
2422 // Global var, const, or let. | 2420 // Global var, const, or let. |
2423 __ mov(StoreDescriptor::NameRegister(), var->name()); | 2421 __ mov(StoreDescriptor::NameRegister(), var->name()); |
2424 __ mov(StoreDescriptor::ReceiverRegister(), NativeContextOperand()); | 2422 __ mov(StoreDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
2425 __ mov(StoreDescriptor::ReceiverRegister(), | |
2426 ContextOperand(StoreDescriptor::ReceiverRegister(), | |
2427 Context::EXTENSION_INDEX)); | |
2428 EmitLoadStoreICSlot(slot); | 2423 EmitLoadStoreICSlot(slot); |
2429 CallStoreIC(); | 2424 CallStoreIC(); |
2430 | 2425 |
2431 } else if (var->mode() == LET && op != Token::INIT) { | 2426 } else if (var->mode() == LET && op != Token::INIT) { |
2432 // Non-initializing assignment to let variable needs a write barrier. | 2427 // Non-initializing assignment to let variable needs a write barrier. |
2433 DCHECK(!var->IsLookupSlot()); | 2428 DCHECK(!var->IsLookupSlot()); |
2434 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); | 2429 DCHECK(var->IsStackAllocated() || var->IsContextSlot()); |
2435 Label assign; | 2430 Label assign; |
2436 MemOperand location = VarOperand(var, ecx); | 2431 MemOperand location = VarOperand(var, ecx); |
2437 __ mov(edx, location); | 2432 __ mov(edx, location); |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4036 | 4031 |
4037 void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) { | 4032 void FullCodeGenerator::EmitCreateIterResultObject(CallRuntime* expr) { |
4038 ZoneList<Expression*>* args = expr->arguments(); | 4033 ZoneList<Expression*>* args = expr->arguments(); |
4039 DCHECK_EQ(2, args->length()); | 4034 DCHECK_EQ(2, args->length()); |
4040 VisitForStackValue(args->at(0)); | 4035 VisitForStackValue(args->at(0)); |
4041 VisitForStackValue(args->at(1)); | 4036 VisitForStackValue(args->at(1)); |
4042 | 4037 |
4043 Label runtime, done; | 4038 Label runtime, done; |
4044 | 4039 |
4045 __ Allocate(JSIteratorResult::kSize, eax, ecx, edx, &runtime, TAG_OBJECT); | 4040 __ Allocate(JSIteratorResult::kSize, eax, ecx, edx, &runtime, TAG_OBJECT); |
4046 __ mov(ebx, NativeContextOperand()); | 4041 __ mov(ebx, GlobalObjectOperand()); |
| 4042 __ mov(ebx, FieldOperand(ebx, JSGlobalObject::kNativeContextOffset)); |
4047 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX)); | 4043 __ mov(ebx, ContextOperand(ebx, Context::ITERATOR_RESULT_MAP_INDEX)); |
4048 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); | 4044 __ mov(FieldOperand(eax, HeapObject::kMapOffset), ebx); |
4049 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), | 4045 __ mov(FieldOperand(eax, JSObject::kPropertiesOffset), |
4050 isolate()->factory()->empty_fixed_array()); | 4046 isolate()->factory()->empty_fixed_array()); |
4051 __ mov(FieldOperand(eax, JSObject::kElementsOffset), | 4047 __ mov(FieldOperand(eax, JSObject::kElementsOffset), |
4052 isolate()->factory()->empty_fixed_array()); | 4048 isolate()->factory()->empty_fixed_array()); |
4053 __ pop(FieldOperand(eax, JSIteratorResult::kDoneOffset)); | 4049 __ pop(FieldOperand(eax, JSIteratorResult::kDoneOffset)); |
4054 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset)); | 4050 __ pop(FieldOperand(eax, JSIteratorResult::kValueOffset)); |
4055 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); | 4051 STATIC_ASSERT(JSIteratorResult::kSize == 5 * kPointerSize); |
4056 __ jmp(&done, Label::kNear); | 4052 __ jmp(&done, Label::kNear); |
4057 | 4053 |
4058 __ bind(&runtime); | 4054 __ bind(&runtime); |
4059 __ CallRuntime(Runtime::kCreateIterResultObject, 2); | 4055 __ CallRuntime(Runtime::kCreateIterResultObject, 2); |
4060 | 4056 |
4061 __ bind(&done); | 4057 __ bind(&done); |
4062 context()->Plug(eax); | 4058 context()->Plug(eax); |
4063 } | 4059 } |
4064 | 4060 |
4065 | 4061 |
4066 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4062 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4067 // Push undefined as receiver. | 4063 // Push undefined as receiver. |
4068 __ push(Immediate(isolate()->factory()->undefined_value())); | 4064 __ push(Immediate(isolate()->factory()->undefined_value())); |
4069 | 4065 |
4070 __ LoadGlobalFunction(expr->context_index(), eax); | 4066 __ mov(eax, GlobalObjectOperand()); |
| 4067 __ mov(eax, FieldOperand(eax, JSGlobalObject::kNativeContextOffset)); |
| 4068 __ mov(eax, ContextOperand(eax, expr->context_index())); |
4071 } | 4069 } |
4072 | 4070 |
4073 | 4071 |
4074 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4072 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4075 ZoneList<Expression*>* args = expr->arguments(); | 4073 ZoneList<Expression*>* args = expr->arguments(); |
4076 int arg_count = args->length(); | 4074 int arg_count = args->length(); |
4077 | 4075 |
4078 SetCallPosition(expr, arg_count); | 4076 SetCallPosition(expr, arg_count); |
4079 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); | 4077 __ mov(edi, Operand(esp, (arg_count + 1) * kPointerSize)); |
4080 __ Set(eax, arg_count); | 4078 __ Set(eax, arg_count); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4149 : Runtime::kDeleteProperty_Sloppy, | 4147 : Runtime::kDeleteProperty_Sloppy, |
4150 2); | 4148 2); |
4151 context()->Plug(eax); | 4149 context()->Plug(eax); |
4152 } else if (proxy != NULL) { | 4150 } else if (proxy != NULL) { |
4153 Variable* var = proxy->var(); | 4151 Variable* var = proxy->var(); |
4154 // Delete of an unqualified identifier is disallowed in strict mode but | 4152 // Delete of an unqualified identifier is disallowed in strict mode but |
4155 // "delete this" is allowed. | 4153 // "delete this" is allowed. |
4156 bool is_this = var->HasThisName(isolate()); | 4154 bool is_this = var->HasThisName(isolate()); |
4157 DCHECK(is_sloppy(language_mode()) || is_this); | 4155 DCHECK(is_sloppy(language_mode()) || is_this); |
4158 if (var->IsUnallocatedOrGlobalSlot()) { | 4156 if (var->IsUnallocatedOrGlobalSlot()) { |
4159 __ mov(eax, NativeContextOperand()); | 4157 __ push(GlobalObjectOperand()); |
4160 __ push(ContextOperand(eax, Context::EXTENSION_INDEX)); | |
4161 __ push(Immediate(var->name())); | 4158 __ push(Immediate(var->name())); |
4162 __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2); | 4159 __ CallRuntime(Runtime::kDeleteProperty_Sloppy, 2); |
4163 context()->Plug(eax); | 4160 context()->Plug(eax); |
4164 } else if (var->IsStackAllocated() || var->IsContextSlot()) { | 4161 } else if (var->IsStackAllocated() || var->IsContextSlot()) { |
4165 // Result of deleting non-global variables is false. 'this' is | 4162 // Result of deleting non-global variables is false. 'this' is |
4166 // not really a variable, though we implement it as one. The | 4163 // not really a variable, though we implement it as one. The |
4167 // subexpression does not have side effects. | 4164 // subexpression does not have side effects. |
4168 context()->Plug(is_this); | 4165 context()->Plug(is_this); |
4169 } else { | 4166 } else { |
4170 // Non-global variable. Call the runtime to try to delete from the | 4167 // Non-global variable. Call the runtime to try to delete from the |
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4715 } | 4712 } |
4716 | 4713 |
4717 | 4714 |
4718 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 4715 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
4719 Scope* closure_scope = scope()->ClosureScope(); | 4716 Scope* closure_scope = scope()->ClosureScope(); |
4720 if (closure_scope->is_script_scope() || | 4717 if (closure_scope->is_script_scope() || |
4721 closure_scope->is_module_scope()) { | 4718 closure_scope->is_module_scope()) { |
4722 // Contexts nested in the native context have a canonical empty function | 4719 // Contexts nested in the native context have a canonical empty function |
4723 // as their closure, not the anonymous closure containing the global | 4720 // as their closure, not the anonymous closure containing the global |
4724 // code. | 4721 // code. |
4725 __ mov(eax, NativeContextOperand()); | 4722 __ mov(eax, GlobalObjectOperand()); |
| 4723 __ mov(eax, FieldOperand(eax, JSGlobalObject::kNativeContextOffset)); |
4726 __ push(ContextOperand(eax, Context::CLOSURE_INDEX)); | 4724 __ push(ContextOperand(eax, Context::CLOSURE_INDEX)); |
4727 } else if (closure_scope->is_eval_scope()) { | 4725 } else if (closure_scope->is_eval_scope()) { |
4728 // Contexts nested inside eval code have the same closure as the context | 4726 // Contexts nested inside eval code have the same closure as the context |
4729 // calling eval, not the anonymous closure containing the eval code. | 4727 // calling eval, not the anonymous closure containing the eval code. |
4730 // Fetch it from the context. | 4728 // Fetch it from the context. |
4731 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); | 4729 __ push(ContextOperand(esi, Context::CLOSURE_INDEX)); |
4732 } else { | 4730 } else { |
4733 DCHECK(closure_scope->is_function_scope()); | 4731 DCHECK(closure_scope->is_function_scope()); |
4734 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 4732 __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
4735 } | 4733 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4874 Assembler::target_address_at(call_target_address, | 4872 Assembler::target_address_at(call_target_address, |
4875 unoptimized_code)); | 4873 unoptimized_code)); |
4876 return OSR_AFTER_STACK_CHECK; | 4874 return OSR_AFTER_STACK_CHECK; |
4877 } | 4875 } |
4878 | 4876 |
4879 | 4877 |
4880 } // namespace internal | 4878 } // namespace internal |
4881 } // namespace v8 | 4879 } // namespace v8 |
4882 | 4880 |
4883 #endif // V8_TARGET_ARCH_IA32 | 4881 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |