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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 | 1252 |
1253 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1253 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1254 Comment cnmt(masm_, "[ SuperReference "); | 1254 Comment cnmt(masm_, "[ SuperReference "); |
1255 | 1255 |
1256 __ mov(LoadDescriptor::ReceiverRegister(), | 1256 __ mov(LoadDescriptor::ReceiverRegister(), |
1257 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1257 Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
1258 | 1258 |
1259 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1259 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1260 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); | 1260 __ mov(LoadDescriptor::NameRegister(), home_object_symbol); |
1261 | 1261 |
1262 if (FLAG_vector_ics) { | 1262 __ mov(VectorLoadICDescriptor::SlotRegister(), |
1263 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1263 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); |
1264 Immediate(SmiFromSlot(expr->HomeObjectFeedbackSlot()))); | 1264 CallLoadIC(NOT_CONTEXTUAL); |
1265 CallLoadIC(NOT_CONTEXTUAL); | |
1266 } else { | |
1267 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); | |
1268 } | |
1269 | 1265 |
1270 __ cmp(eax, isolate()->factory()->undefined_value()); | 1266 __ cmp(eax, isolate()->factory()->undefined_value()); |
1271 Label done; | 1267 Label done; |
1272 __ j(not_equal, &done); | 1268 __ j(not_equal, &done); |
1273 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1269 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1274 __ bind(&done); | 1270 __ bind(&done); |
1275 } | 1271 } |
1276 | 1272 |
1277 | 1273 |
1278 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1274 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 // Load next context in chain. | 1329 // Load next context in chain. |
1334 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1330 __ mov(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1335 __ jmp(&next); | 1331 __ jmp(&next); |
1336 __ bind(&fast); | 1332 __ bind(&fast); |
1337 } | 1333 } |
1338 | 1334 |
1339 // All extension objects were empty and it is safe to use a global | 1335 // All extension objects were empty and it is safe to use a global |
1340 // load IC call. | 1336 // load IC call. |
1341 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1337 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1342 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1338 __ mov(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1343 if (FLAG_vector_ics) { | 1339 __ mov(VectorLoadICDescriptor::SlotRegister(), |
1344 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1340 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1345 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | |
1346 } | |
1347 | 1341 |
1348 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1342 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1349 ? NOT_CONTEXTUAL | 1343 ? NOT_CONTEXTUAL |
1350 : CONTEXTUAL; | 1344 : CONTEXTUAL; |
1351 | 1345 |
1352 CallLoadIC(mode); | 1346 CallLoadIC(mode); |
1353 } | 1347 } |
1354 | 1348 |
1355 | 1349 |
1356 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1350 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1421 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1415 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1422 Variable* var = proxy->var(); | 1416 Variable* var = proxy->var(); |
1423 | 1417 |
1424 // Three cases: global variables, lookup variables, and all other types of | 1418 // Three cases: global variables, lookup variables, and all other types of |
1425 // variables. | 1419 // variables. |
1426 switch (var->location()) { | 1420 switch (var->location()) { |
1427 case Variable::UNALLOCATED: { | 1421 case Variable::UNALLOCATED: { |
1428 Comment cmnt(masm_, "[ Global variable"); | 1422 Comment cmnt(masm_, "[ Global variable"); |
1429 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1423 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1430 __ mov(LoadDescriptor::NameRegister(), var->name()); | 1424 __ mov(LoadDescriptor::NameRegister(), var->name()); |
1431 if (FLAG_vector_ics) { | 1425 __ mov(VectorLoadICDescriptor::SlotRegister(), |
1432 __ mov(VectorLoadICDescriptor::SlotRegister(), | 1426 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
1433 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | |
1434 } | |
1435 CallGlobalLoadIC(var->name()); | 1427 CallGlobalLoadIC(var->name()); |
1436 context()->Plug(eax); | 1428 context()->Plug(eax); |
1437 break; | 1429 break; |
1438 } | 1430 } |
1439 | 1431 |
1440 case Variable::PARAMETER: | 1432 case Variable::PARAMETER: |
1441 case Variable::LOCAL: | 1433 case Variable::LOCAL: |
1442 case Variable::CONTEXT: { | 1434 case Variable::CONTEXT: { |
1443 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" | 1435 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context variable" |
1444 : "[ Stack variable"); | 1436 : "[ Stack variable"); |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2118 __ bind(&l_next); | 2110 __ bind(&l_next); |
2119 | 2111 |
2120 __ mov(load_name, isolate()->factory()->next_string()); | 2112 __ mov(load_name, isolate()->factory()->next_string()); |
2121 __ push(load_name); // "next" | 2113 __ push(load_name); // "next" |
2122 __ push(Operand(esp, 2 * kPointerSize)); // iter | 2114 __ push(Operand(esp, 2 * kPointerSize)); // iter |
2123 __ push(eax); // received | 2115 __ push(eax); // received |
2124 | 2116 |
2125 // result = receiver[f](arg); | 2117 // result = receiver[f](arg); |
2126 __ bind(&l_call); | 2118 __ bind(&l_call); |
2127 __ mov(load_receiver, Operand(esp, kPointerSize)); | 2119 __ mov(load_receiver, Operand(esp, kPointerSize)); |
2128 if (FLAG_vector_ics) { | 2120 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2129 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2121 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); |
2130 Immediate(SmiFromSlot(expr->KeyedLoadFeedbackSlot()))); | |
2131 } | |
2132 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2122 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2133 CallIC(ic, TypeFeedbackId::None()); | 2123 CallIC(ic, TypeFeedbackId::None()); |
2134 __ mov(edi, eax); | 2124 __ mov(edi, eax); |
2135 __ mov(Operand(esp, 2 * kPointerSize), edi); | 2125 __ mov(Operand(esp, 2 * kPointerSize), edi); |
2136 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2126 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2137 __ CallStub(&stub); | 2127 __ CallStub(&stub); |
2138 | 2128 |
2139 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); | 2129 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); |
2140 __ Drop(1); // The function is still on the stack; drop it. | 2130 __ Drop(1); // The function is still on the stack; drop it. |
2141 | 2131 |
2142 // if (!result.done) goto l_try; | 2132 // if (!result.done) goto l_try; |
2143 __ bind(&l_loop); | 2133 __ bind(&l_loop); |
2144 __ push(eax); // save result | 2134 __ push(eax); // save result |
2145 __ Move(load_receiver, eax); // result | 2135 __ Move(load_receiver, eax); // result |
2146 __ mov(load_name, | 2136 __ mov(load_name, |
2147 isolate()->factory()->done_string()); // "done" | 2137 isolate()->factory()->done_string()); // "done" |
2148 if (FLAG_vector_ics) { | 2138 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2149 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2139 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); |
2150 Immediate(SmiFromSlot(expr->DoneFeedbackSlot()))); | |
2151 } | |
2152 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax | 2140 CallLoadIC(NOT_CONTEXTUAL); // result.done in eax |
2153 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2141 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2154 CallIC(bool_ic); | 2142 CallIC(bool_ic); |
2155 __ test(eax, eax); | 2143 __ test(eax, eax); |
2156 __ j(zero, &l_try); | 2144 __ j(zero, &l_try); |
2157 | 2145 |
2158 // result.value | 2146 // result.value |
2159 __ pop(load_receiver); // result | 2147 __ pop(load_receiver); // result |
2160 __ mov(load_name, | 2148 __ mov(load_name, |
2161 isolate()->factory()->value_string()); // "value" | 2149 isolate()->factory()->value_string()); // "value" |
2162 if (FLAG_vector_ics) { | 2150 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2163 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2151 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); |
2164 Immediate(SmiFromSlot(expr->ValueFeedbackSlot()))); | |
2165 } | |
2166 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax | 2152 CallLoadIC(NOT_CONTEXTUAL); // result.value in eax |
2167 context()->DropAndPlug(2, eax); // drop iter and g | 2153 context()->DropAndPlug(2, eax); // drop iter and g |
2168 break; | 2154 break; |
2169 } | 2155 } |
2170 } | 2156 } |
2171 } | 2157 } |
2172 | 2158 |
2173 | 2159 |
2174 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2160 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2175 Expression *value, | 2161 Expression *value, |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 } | 2279 } |
2294 | 2280 |
2295 | 2281 |
2296 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2282 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2297 SetSourcePosition(prop->position()); | 2283 SetSourcePosition(prop->position()); |
2298 Literal* key = prop->key()->AsLiteral(); | 2284 Literal* key = prop->key()->AsLiteral(); |
2299 DCHECK(!key->value()->IsSmi()); | 2285 DCHECK(!key->value()->IsSmi()); |
2300 DCHECK(!prop->IsSuperAccess()); | 2286 DCHECK(!prop->IsSuperAccess()); |
2301 | 2287 |
2302 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); | 2288 __ mov(LoadDescriptor::NameRegister(), Immediate(key->value())); |
2303 if (FLAG_vector_ics) { | 2289 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2304 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2290 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2305 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2291 CallLoadIC(NOT_CONTEXTUAL); |
2306 CallLoadIC(NOT_CONTEXTUAL); | |
2307 } else { | |
2308 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | |
2309 } | |
2310 } | 2292 } |
2311 | 2293 |
2312 | 2294 |
2313 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2295 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2314 // Stack: receiver, home_object. | 2296 // Stack: receiver, home_object. |
2315 SetSourcePosition(prop->position()); | 2297 SetSourcePosition(prop->position()); |
2316 Literal* key = prop->key()->AsLiteral(); | 2298 Literal* key = prop->key()->AsLiteral(); |
2317 DCHECK(!key->value()->IsSmi()); | 2299 DCHECK(!key->value()->IsSmi()); |
2318 DCHECK(prop->IsSuperAccess()); | 2300 DCHECK(prop->IsSuperAccess()); |
2319 | 2301 |
2320 __ push(Immediate(key->value())); | 2302 __ push(Immediate(key->value())); |
2321 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2303 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2322 } | 2304 } |
2323 | 2305 |
2324 | 2306 |
2325 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2307 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2326 SetSourcePosition(prop->position()); | 2308 SetSourcePosition(prop->position()); |
2327 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2309 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2328 if (FLAG_vector_ics) { | 2310 __ mov(VectorLoadICDescriptor::SlotRegister(), |
2329 __ mov(VectorLoadICDescriptor::SlotRegister(), | 2311 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); |
2330 Immediate(SmiFromSlot(prop->PropertyFeedbackSlot()))); | 2312 CallIC(ic); |
2331 CallIC(ic); | |
2332 } else { | |
2333 CallIC(ic, prop->PropertyFeedbackId()); | |
2334 } | |
2335 } | 2313 } |
2336 | 2314 |
2337 | 2315 |
2338 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2316 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2339 // Stack: receiver, home_object, key. | 2317 // Stack: receiver, home_object, key. |
2340 SetSourcePosition(prop->position()); | 2318 SetSourcePosition(prop->position()); |
2341 | 2319 |
2342 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2320 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2343 } | 2321 } |
2344 | 2322 |
(...skipping 2201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4546 | 4524 |
4547 | 4525 |
4548 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4526 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4549 // Push the builtins object as receiver. | 4527 // Push the builtins object as receiver. |
4550 __ mov(eax, GlobalObjectOperand()); | 4528 __ mov(eax, GlobalObjectOperand()); |
4551 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); | 4529 __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset)); |
4552 | 4530 |
4553 // Load the function from the receiver. | 4531 // Load the function from the receiver. |
4554 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); | 4532 __ mov(LoadDescriptor::ReceiverRegister(), Operand(esp, 0)); |
4555 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); | 4533 __ mov(LoadDescriptor::NameRegister(), Immediate(expr->name())); |
4556 if (FLAG_vector_ics) { | 4534 __ mov(VectorLoadICDescriptor::SlotRegister(), |
4557 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4535 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); |
4558 Immediate(SmiFromSlot(expr->CallRuntimeFeedbackSlot()))); | 4536 CallLoadIC(NOT_CONTEXTUAL); |
4559 CallLoadIC(NOT_CONTEXTUAL); | |
4560 } else { | |
4561 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4562 } | |
4563 } | 4537 } |
4564 | 4538 |
4565 | 4539 |
4566 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4540 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4567 ZoneList<Expression*>* args = expr->arguments(); | 4541 ZoneList<Expression*>* args = expr->arguments(); |
4568 int arg_count = args->length(); | 4542 int arg_count = args->length(); |
4569 | 4543 |
4570 // Record source position of the IC call. | 4544 // Record source position of the IC call. |
4571 SetSourcePosition(expr->position()); | 4545 SetSourcePosition(expr->position()); |
4572 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4546 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 | 4965 |
4992 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4966 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4993 VariableProxy* proxy = expr->AsVariableProxy(); | 4967 VariableProxy* proxy = expr->AsVariableProxy(); |
4994 DCHECK(!context()->IsEffect()); | 4968 DCHECK(!context()->IsEffect()); |
4995 DCHECK(!context()->IsTest()); | 4969 DCHECK(!context()->IsTest()); |
4996 | 4970 |
4997 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4971 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4998 Comment cmnt(masm_, "[ Global variable"); | 4972 Comment cmnt(masm_, "[ Global variable"); |
4999 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4973 __ mov(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
5000 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); | 4974 __ mov(LoadDescriptor::NameRegister(), Immediate(proxy->name())); |
5001 if (FLAG_vector_ics) { | 4975 __ mov(VectorLoadICDescriptor::SlotRegister(), |
5002 __ mov(VectorLoadICDescriptor::SlotRegister(), | 4976 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); |
5003 Immediate(SmiFromSlot(proxy->VariableFeedbackSlot()))); | |
5004 } | |
5005 // Use a regular load, not a contextual load, to avoid a reference | 4977 // Use a regular load, not a contextual load, to avoid a reference |
5006 // error. | 4978 // error. |
5007 CallLoadIC(NOT_CONTEXTUAL); | 4979 CallLoadIC(NOT_CONTEXTUAL); |
5008 PrepareForBailout(expr, TOS_REG); | 4980 PrepareForBailout(expr, TOS_REG); |
5009 context()->Plug(eax); | 4981 context()->Plug(eax); |
5010 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4982 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
5011 Comment cmnt(masm_, "[ Lookup slot"); | 4983 Comment cmnt(masm_, "[ Lookup slot"); |
5012 Label done, slow; | 4984 Label done, slow; |
5013 | 4985 |
5014 // Generate code for loading from variables potentially shadowed | 4986 // Generate code for loading from variables potentially shadowed |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5374 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5346 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5375 Assembler::target_address_at(call_target_address, | 5347 Assembler::target_address_at(call_target_address, |
5376 unoptimized_code)); | 5348 unoptimized_code)); |
5377 return OSR_AFTER_STACK_CHECK; | 5349 return OSR_AFTER_STACK_CHECK; |
5378 } | 5350 } |
5379 | 5351 |
5380 | 5352 |
5381 } } // namespace v8::internal | 5353 } } // namespace v8::internal |
5382 | 5354 |
5383 #endif // V8_TARGET_ARCH_IA32 | 5355 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |