| 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 #include "src/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 8 | 8 |
| 9 #include "src/code-factory.h" | 9 #include "src/code-factory.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool function_in_register = true; | 183 bool function_in_register = true; |
| 184 | 184 |
| 185 // Possibly allocate a local context. | 185 // Possibly allocate a local context. |
| 186 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 186 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 187 if (heap_slots > 0) { | 187 if (heap_slots > 0) { |
| 188 Comment cmnt(masm_, "[ Allocate context"); | 188 Comment cmnt(masm_, "[ Allocate context"); |
| 189 bool need_write_barrier = true; | 189 bool need_write_barrier = true; |
| 190 // Argument to NewContext is the function, which is still in edi. | 190 // Argument to NewContext is the function, which is still in edi. |
| 191 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 191 if (FLAG_harmony_scoping && info->scope()->is_script_scope()) { |
| 192 __ push(edi); | 192 __ push(edi); |
| 193 __ Push(info->scope()->GetScopeInfo()); | 193 __ Push(info->scope()->GetScopeInfo()); |
| 194 __ CallRuntime(Runtime::kNewGlobalContext, 2); | 194 __ CallRuntime(Runtime::kNewScriptContext, 2); |
| 195 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 195 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| 196 FastNewContextStub stub(isolate(), heap_slots); | 196 FastNewContextStub stub(isolate(), heap_slots); |
| 197 __ CallStub(&stub); | 197 __ CallStub(&stub); |
| 198 // Result of FastNewContextStub is always in new space. | 198 // Result of FastNewContextStub is always in new space. |
| 199 need_write_barrier = false; | 199 need_write_barrier = false; |
| 200 } else { | 200 } else { |
| 201 __ push(edi); | 201 __ push(edi); |
| 202 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 202 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
| 203 } | 203 } |
| 204 function_in_register = false; | 204 function_in_register = false; |
| (...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 | 865 |
| 866 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { | 866 void FullCodeGenerator::VisitModuleDeclaration(ModuleDeclaration* declaration) { |
| 867 Variable* variable = declaration->proxy()->var(); | 867 Variable* variable = declaration->proxy()->var(); |
| 868 DCHECK(variable->location() == Variable::CONTEXT); | 868 DCHECK(variable->location() == Variable::CONTEXT); |
| 869 DCHECK(variable->interface()->IsFrozen()); | 869 DCHECK(variable->interface()->IsFrozen()); |
| 870 | 870 |
| 871 Comment cmnt(masm_, "[ ModuleDeclaration"); | 871 Comment cmnt(masm_, "[ ModuleDeclaration"); |
| 872 EmitDebugCheckDeclarationContext(variable); | 872 EmitDebugCheckDeclarationContext(variable); |
| 873 | 873 |
| 874 // Load instance object. | 874 // Load instance object. |
| 875 __ LoadContext(eax, scope_->ContextChainLength(scope_->GlobalScope())); | 875 __ LoadContext(eax, scope_->ContextChainLength(scope_->ScriptScope())); |
| 876 __ mov(eax, ContextOperand(eax, variable->interface()->Index())); | 876 __ mov(eax, ContextOperand(eax, variable->interface()->Index())); |
| 877 __ mov(eax, ContextOperand(eax, Context::EXTENSION_INDEX)); | 877 __ mov(eax, ContextOperand(eax, Context::EXTENSION_INDEX)); |
| 878 | 878 |
| 879 // Assign it. | 879 // Assign it. |
| 880 __ mov(ContextOperand(esi, variable->index()), eax); | 880 __ mov(ContextOperand(esi, variable->index()), eax); |
| 881 // We know that we have written a module, which is not a smi. | 881 // We know that we have written a module, which is not a smi. |
| 882 __ RecordWriteContextSlot(esi, | 882 __ RecordWriteContextSlot(esi, |
| 883 Context::SlotOffset(variable->index()), | 883 Context::SlotOffset(variable->index()), |
| 884 eax, | 884 eax, |
| 885 ecx, | 885 ecx, |
| (...skipping 4138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5024 } | 5024 } |
| 5025 | 5025 |
| 5026 | 5026 |
| 5027 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { | 5027 void FullCodeGenerator::LoadContextField(Register dst, int context_index) { |
| 5028 __ mov(dst, ContextOperand(esi, context_index)); | 5028 __ mov(dst, ContextOperand(esi, context_index)); |
| 5029 } | 5029 } |
| 5030 | 5030 |
| 5031 | 5031 |
| 5032 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { | 5032 void FullCodeGenerator::PushFunctionArgumentForContextAllocation() { |
| 5033 Scope* declaration_scope = scope()->DeclarationScope(); | 5033 Scope* declaration_scope = scope()->DeclarationScope(); |
| 5034 if (declaration_scope->is_global_scope() || | 5034 if (declaration_scope->is_script_scope() || |
| 5035 declaration_scope->is_module_scope()) { | 5035 declaration_scope->is_module_scope()) { |
| 5036 // Contexts nested in the native context have a canonical empty function | 5036 // Contexts nested in the native context have a canonical empty function |
| 5037 // as their closure, not the anonymous closure containing the global | 5037 // as their closure, not the anonymous closure containing the global |
| 5038 // code. Pass a smi sentinel and let the runtime look up the empty | 5038 // code. Pass a smi sentinel and let the runtime look up the empty |
| 5039 // function. | 5039 // function. |
| 5040 __ push(Immediate(Smi::FromInt(0))); | 5040 __ push(Immediate(Smi::FromInt(0))); |
| 5041 } else if (declaration_scope->is_eval_scope()) { | 5041 } else if (declaration_scope->is_eval_scope()) { |
| 5042 // Contexts nested inside eval code have the same closure as the context | 5042 // Contexts nested inside eval code have the same closure as the context |
| 5043 // calling eval, not the anonymous closure containing the eval code. | 5043 // calling eval, not the anonymous closure containing the eval code. |
| 5044 // Fetch it from the context. | 5044 // Fetch it from the context. |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5218 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5218 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
| 5219 Assembler::target_address_at(call_target_address, | 5219 Assembler::target_address_at(call_target_address, |
| 5220 unoptimized_code)); | 5220 unoptimized_code)); |
| 5221 return OSR_AFTER_STACK_CHECK; | 5221 return OSR_AFTER_STACK_CHECK; |
| 5222 } | 5222 } |
| 5223 | 5223 |
| 5224 | 5224 |
| 5225 } } // namespace v8::internal | 5225 } } // namespace v8::internal |
| 5226 | 5226 |
| 5227 #endif // V8_TARGET_ARCH_IA32 | 5227 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |