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 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1253 | 1253 |
1254 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1254 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1255 Comment cnmt(masm_, "[ SuperReference "); | 1255 Comment cnmt(masm_, "[ SuperReference "); |
1256 | 1256 |
1257 __ mov(LoadDescriptor::ReceiverRegister(), | 1257 __ mov(LoadDescriptor::ReceiverRegister(), |
1258 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1258 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1259 | 1259 |
1260 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1260 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1261 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); | 1261 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); |
1262 | 1262 |
1263 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1263 __ mov(LoadDescriptor::SlotRegister(), |
1264 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); | 1264 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); |
1265 CallLoadIC(NOT_CONTEXTUAL); | 1265 CallLoadIC(NOT_CONTEXTUAL); |
1266 | 1266 |
1267 __ cmp(eax, isolate()->factory()->undefined_value()); | 1267 __ cmp(eax, isolate()->factory()->undefined_value()); |
1268 Label done; | 1268 Label done; |
1269 __ j(not_equal, &done); | 1269 __ j(not_equal, &done); |
1270 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1270 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1271 __ bind(&done); | 1271 __ bind(&done); |
1272 } | 1272 } |
1273 | 1273 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1330 // Load next context in chain. | 1330 // Load next context in chain. |
1331 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1331 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1332 __ jmp(&next); | 1332 __ jmp(&next); |
1333 __ bind(&fast); | 1333 __ bind(&fast); |
1334 } | 1334 } |
1335 | 1335 |
1336 // All extension objects were empty and it is safe to use a global | 1336 // All extension objects were empty and it is safe to use a global |
1337 // load IC call. | 1337 // load IC call. |
1338 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1338 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1339 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1339 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1340 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1340 __ mov(LoadDescriptor::SlotRegister(), |
1341 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1341 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1342 | 1342 |
1343 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1343 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1344 ? NOT_CONTEXTUAL | 1344 ? NOT_CONTEXTUAL |
1345 : CONTEXTUAL; | 1345 : CONTEXTUAL; |
1346 | 1346 |
1347 CallLoadIC(mode); | 1347 CallLoadIC(mode); |
1348 } | 1348 } |
1349 | 1349 |
1350 | 1350 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1416 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1416 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1417 Variable* var = proxy->var(); | 1417 Variable* var = proxy->var(); |
1418 | 1418 |
1419 // Three cases: global variables, lookup variables, and all other types of | 1419 // Three cases: global variables, lookup variables, and all other types of |
1420 // variables. | 1420 // variables. |
1421 switch (var->location()) { | 1421 switch (var->location()) { |
1422 case Variable::UNALLOCATED: { | 1422 case Variable::UNALLOCATED: { |
1423 Comment cmnt(masm_, "[ Global variable"); | 1423 Comment cmnt(masm_, "[ Global variable"); |
1424 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1424 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1425 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1425 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1426 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1426 __ mov(LoadDescriptor::SlotRegister(), |
1427 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 1427 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1428 CallGlobalLoadIC(var->name()); | 1428 CallGlobalLoadIC(var->name()); |
1429 context()->Plug(eax); | 1429 context()->Plug(eax); |
1430 break; | 1430 break; |
1431 } | 1431 } |
1432 | 1432 |
1433 case Variable::PARAMETER: | 1433 case Variable::PARAMETER: |
1434 case Variable::LOCAL: | 1434 case Variable::LOCAL: |
1435 case Variable::CONTEXT: { | 1435 case Variable::CONTEXT: { |
1436 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1436 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 __ bind(&l_next); | 2111 __ bind(&l_next); |
2112 | 2112 |
2113 __ mov(load_name, isolate()->factory()->next_string()); | 2113 __ mov(load_name, isolate()->factory()->next_string()); |
2114 __ push(load_name); // "next" | 2114 __ push(load_name); // "next" |
2115 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2115 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2116 __ push(eax); // received | 2116 __ push(eax); // received |
2117 | 2117 |
2118 // result = receiver[f](arg); | 2118 // result = receiver[f](arg); |
2119 __ bind(&l_call); | 2119 __ bind(&l_call); |
2120 __ mov(load_receiver, Operand(esp, kPointerSize)); | 2120 __ mov(load_receiver, Operand(esp, kPointerSize)); |
2121 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2121 __ mov(LoadDescriptor::SlotRegister(), |
2122 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | 2122 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
2123 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2123 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2124 CallIC(ic, TypeFeedbackId::None()); | 2124 CallIC(ic, TypeFeedbackId::None()); |
2125 __ mov(edi, eax); | 2125 __ mov(edi, eax); |
2126 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2126 __ mov(Operand(esp, 2 * kPointerSize), edi); |
2127 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2127 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2128 __ CallStub(&stub); | 2128 __ CallStub(&stub); |
2129 | 2129 |
2130 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2130 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2131 __ Drop(1); // The function is still on the stack; drop it. | 2131 __ Drop(1); // The function is still on the stack; drop it. |
2132 | 2132 |
2133 // if (!result.done) goto l_try; | 2133 // if (!result.done) goto l_try; |
2134 __ bind(&l_loop); | 2134 __ bind(&l_loop); |
2135 __ push(eax); // save result | 2135 __ push(eax); // save result |
2136 __ Move(load_receiver, eax); // result | 2136 __ Move(load_receiver, eax); // result |
2137 __ mov(load_name, | 2137 __ mov(load_name, |
2138 isolate()->factory()->done_string()); // "done" | 2138 isolate()->factory()->done_string()); // "done" |
2139 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2139 __ mov(LoadDescriptor::SlotRegister(), |
2140 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); | 2140 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); |
2141 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax | 2141 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax |
2142 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2142 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2143 CallIC(bool_ic); | 2143 CallIC(bool_ic); |
2144 __ test(eax, eax); | 2144 __ test(eax, eax); |
2145 __ j(zero, &l_try); | 2145 __ j(zero, &l_try); |
2146 | 2146 |
2147 // result.value | 2147 // result.value |
2148 __ pop(load_receiver); // result | 2148 __ pop(load_receiver); // result |
2149 __ mov(load_name, | 2149 __ mov(load_name, |
2150 isolate()->factory()->value_string()); // "value" | 2150 isolate()->factory()->value_string()); // "value" |
2151 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2151 __ mov(LoadDescriptor::SlotRegister(), |
2152 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); | 2152 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); |
2153 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax | 2153 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax |
2154 context()->DropAndPlug(2, eax); // drop iter and g | 2154 context()->DropAndPlug(2, eax); // drop iter and g |
2155 break; | 2155 break; |
2156 } | 2156 } |
2157 } | 2157 } |
2158 } | 2158 } |
2159 | 2159 |
2160 | 2160 |
2161 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2161 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2280 } | 2280 } |
2281 | 2281 |
2282 | 2282 |
2283 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2283 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2284 SetSourcePosition(prop->position()); | 2284 SetSourcePosition(prop->position()); |
2285 Literal* key = prop->key()->AsLiteral(); | 2285 Literal* key = prop->key()->AsLiteral(); |
2286 DCHECK(!key->value()->IsSmi()); | 2286 DCHECK(!key->value()->IsSmi()); |
2287 DCHECK(!prop->IsSuperAccess()); | 2287 DCHECK(!prop->IsSuperAccess()); |
2288 | 2288 |
2289 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); | 2289 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); |
2290 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2290 __ mov(LoadDescriptor::SlotRegister(), |
2291 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2291 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2292 CallLoadIC(NOT_CONTEXTUAL); | 2292 CallLoadIC(NOT_CONTEXTUAL); |
2293 } | 2293 } |
2294 | 2294 |
2295 | 2295 |
2296 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2296 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2297 // Stack: receiver, home_object. | 2297 // Stack: receiver, home_object. |
2298 SetSourcePosition(prop->position()); | 2298 SetSourcePosition(prop->position()); |
2299 Literal* key = prop->key()->AsLiteral(); | 2299 Literal* key = prop->key()->AsLiteral(); |
2300 DCHECK(!key->value()->IsSmi()); | 2300 DCHECK(!key->value()->IsSmi()); |
2301 DCHECK(prop->IsSuperAccess()); | 2301 DCHECK(prop->IsSuperAccess()); |
2302 | 2302 |
2303 __ push(Immediate(key->value())); | 2303 __ push(Immediate(key->value())); |
2304 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2304 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2305 } | 2305 } |
2306 | 2306 |
2307 | 2307 |
2308 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2308 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2309 SetSourcePosition(prop->position()); | 2309 SetSourcePosition(prop->position()); |
2310 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2310 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2311 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2311 __ mov(LoadDescriptor::SlotRegister(), |
2312 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2312 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2313 CallIC(ic); | 2313 CallIC(ic); |
2314 } | 2314 } |
2315 | 2315 |
2316 | 2316 |
2317 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2317 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2318 // Stack: receiver, home_object, key. | 2318 // Stack: receiver, home_object, key. |
2319 SetSourcePosition(prop->position()); | 2319 SetSourcePosition(prop->position()); |
2320 | 2320 |
2321 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2321 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
(...skipping 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4527 | 4527 |
4528 | 4528 |
4529 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4529 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4530 // Push the builtins object as receiver. | 4530 // Push the builtins object as receiver. |
4531 __ mov(eax, GlobalObjectOperand()); | 4531 __ mov(eax, GlobalObjectOperand()); |
4532 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4532 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
4533 | 4533 |
4534 // Load the function from the receiver. | 4534 // Load the function from the receiver. |
4535 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4535 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
4536 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); | 4536 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); |
4537 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4537 __ mov(LoadDescriptor::SlotRegister(), |
4538 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4538 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
4539 CallLoadIC(NOT_CONTEXTUAL); | 4539 CallLoadIC(NOT_CONTEXTUAL); |
4540 } | 4540 } |
4541 | 4541 |
4542 | 4542 |
4543 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4543 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4544 ZoneList<Expression*>* args = expr->arguments(); | 4544 ZoneList<Expression*>* args = expr->arguments(); |
4545 int arg_count = args->length(); | 4545 int arg_count = args->length(); |
4546 | 4546 |
4547 // Record source position of the IC call. | 4547 // Record source position of the IC call. |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4968 | 4968 |
4969 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4969 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4970 VariableProxy* proxy = expr->AsVariableProxy(); | 4970 VariableProxy* proxy = expr->AsVariableProxy(); |
4971 DCHECK(!context()->IsEffect()); | 4971 DCHECK(!context()->IsEffect()); |
4972 DCHECK(!context()->IsTest()); | 4972 DCHECK(!context()->IsTest()); |
4973 | 4973 |
4974 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4974 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4975 Comment cmnt(masm_, "[ Global variable"); | 4975 Comment cmnt(masm_, "[ Global variable"); |
4976 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4976 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
4977 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); | 4977 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); |
4978 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4978 __ mov(LoadDescriptor::SlotRegister(), |
4979 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | 4979 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
4980 // Use a regular load, not a contextual load, to avoid a reference | 4980 // Use a regular load, not a contextual load, to avoid a reference |
4981 // error. | 4981 // error. |
4982 CallLoadIC(NOT_CONTEXTUAL); | 4982 CallLoadIC(NOT_CONTEXTUAL); |
4983 PrepareForBailout(expr, TOS_REG); | 4983 PrepareForBailout(expr, TOS_REG); |
4984 context()->Plug(eax); | 4984 context()->Plug(eax); |
4985 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4985 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
4986 Comment cmnt(masm_, "[ Lookup slot"); | 4986 Comment cmnt(masm_, "[ Lookup slot"); |
4987 Label done, slow; | 4987 Label done, slow; |
4988 | 4988 |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5349 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5349 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5350 Assembler::target_address_at(call_target_address, | 5350 Assembler::target_address_at(call_target_address, |
5351 unoptimized_code)); | 5351 unoptimized_code)); |
5352 return OSR_AFTER_STACK_CHECK; | 5352 return OSR_AFTER_STACK_CHECK; |
5353 } | 5353 } |
5354 | 5354 |
5355 | 5355 |
5356 } } // namespace v8::internal | 5356 } } // namespace v8::internal |
5357 | 5357 |
5358 #endif // V8_TARGET_ARCH_IA32 | 5358 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |