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_X64 | 7 #if V8_TARGET_ARCH_X64 |
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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 | 1287 |
1288 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1288 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1289 Comment cnmt(masm_, "[ SuperReference "); | 1289 Comment cnmt(masm_, "[ SuperReference "); |
1290 | 1290 |
1291 __ movp(LoadDescriptor::ReceiverRegister(), | 1291 __ movp(LoadDescriptor::ReceiverRegister(), |
1292 Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1292 Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1293 | 1293 |
1294 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1294 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1295 __ Move(LoadDescriptor::NameRegister(), home_object_symbol); | 1295 __ Move(LoadDescriptor::NameRegister(), home_object_symbol); |
1296 | 1296 |
1297 if (FLAG_vector_ics) { | 1297 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1298 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1298 SmiFromSlot(expr->HomeObjectFeedbackSlot())); |
1299 SmiFromSlot(expr->HomeObjectFeedbackSlot())); | 1299 CallLoadIC(NOT_CONTEXTUAL); |
1300 CallLoadIC(NOT_CONTEXTUAL); | |
1301 } else { | |
1302 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); | |
1303 } | |
1304 | |
1305 | 1300 |
1306 __ Cmp(rax, isolate()->factory()->undefined_value()); | 1301 __ Cmp(rax, isolate()->factory()->undefined_value()); |
1307 Label done; | 1302 Label done; |
1308 __ j(not_equal, &done); | 1303 __ j(not_equal, &done); |
1309 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1304 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1310 __ bind(&done); | 1305 __ bind(&done); |
1311 } | 1306 } |
1312 | 1307 |
1313 | 1308 |
1314 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, | 1309 void FullCodeGenerator::EmitSetHomeObjectIfNeeded(Expression* initializer, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1370 // Load next context in chain. | 1365 // Load next context in chain. |
1371 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1366 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1372 __ jmp(&next); | 1367 __ jmp(&next); |
1373 __ bind(&fast); | 1368 __ bind(&fast); |
1374 } | 1369 } |
1375 | 1370 |
1376 // All extension objects were empty and it is safe to use a global | 1371 // All extension objects were empty and it is safe to use a global |
1377 // load IC call. | 1372 // load IC call. |
1378 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1373 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1379 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1374 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1380 if (FLAG_vector_ics) { | 1375 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1381 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1376 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1382 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1383 } | |
1384 | 1377 |
1385 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1378 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1386 ? NOT_CONTEXTUAL | 1379 ? NOT_CONTEXTUAL |
1387 : CONTEXTUAL; | 1380 : CONTEXTUAL; |
1388 CallLoadIC(mode); | 1381 CallLoadIC(mode); |
1389 } | 1382 } |
1390 | 1383 |
1391 | 1384 |
1392 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1385 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
1393 Label* slow) { | 1386 Label* slow) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1457 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1450 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1458 Variable* var = proxy->var(); | 1451 Variable* var = proxy->var(); |
1459 | 1452 |
1460 // Three cases: global variables, lookup variables, and all other types of | 1453 // Three cases: global variables, lookup variables, and all other types of |
1461 // variables. | 1454 // variables. |
1462 switch (var->location()) { | 1455 switch (var->location()) { |
1463 case Variable::UNALLOCATED: { | 1456 case Variable::UNALLOCATED: { |
1464 Comment cmnt(masm_, "[ Global variable"); | 1457 Comment cmnt(masm_, "[ Global variable"); |
1465 __ Move(LoadDescriptor::NameRegister(), var->name()); | 1458 __ Move(LoadDescriptor::NameRegister(), var->name()); |
1466 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1459 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1467 if (FLAG_vector_ics) { | 1460 __ Move(VectorLoadICDescriptor::SlotRegister(), |
1468 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1461 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1469 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1470 } | |
1471 CallGlobalLoadIC(var->name()); | 1462 CallGlobalLoadIC(var->name()); |
1472 context()->Plug(rax); | 1463 context()->Plug(rax); |
1473 break; | 1464 break; |
1474 } | 1465 } |
1475 | 1466 |
1476 case Variable::PARAMETER: | 1467 case Variable::PARAMETER: |
1477 case Variable::LOCAL: | 1468 case Variable::LOCAL: |
1478 case Variable::CONTEXT: { | 1469 case Variable::CONTEXT: { |
1479 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" | 1470 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" |
1480 : "[ Stack slot"); | 1471 : "[ Stack slot"); |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2152 __ bind(&l_next); | 2143 __ bind(&l_next); |
2153 | 2144 |
2154 __ LoadRoot(load_name, Heap::knext_stringRootIndex); | 2145 __ LoadRoot(load_name, Heap::knext_stringRootIndex); |
2155 __ Push(load_name); // "next" | 2146 __ Push(load_name); // "next" |
2156 __ Push(Operand(rsp, 2 * kPointerSize)); // iter | 2147 __ Push(Operand(rsp, 2 * kPointerSize)); // iter |
2157 __ Push(rax); // received | 2148 __ Push(rax); // received |
2158 | 2149 |
2159 // result = receiver[f](arg); | 2150 // result = receiver[f](arg); |
2160 __ bind(&l_call); | 2151 __ bind(&l_call); |
2161 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 2152 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
2162 if (FLAG_vector_ics) { | 2153 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2163 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2154 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
2164 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | |
2165 } | |
2166 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2155 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2167 CallIC(ic, TypeFeedbackId::None()); | 2156 CallIC(ic, TypeFeedbackId::None()); |
2168 __ movp(rdi, rax); | 2157 __ movp(rdi, rax); |
2169 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2158 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
2170 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2159 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2171 __ CallStub(&stub); | 2160 __ CallStub(&stub); |
2172 | 2161 |
2173 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2162 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2174 __ Drop(1); // The function is still on the stack; drop it. | 2163 __ Drop(1); // The function is still on the stack; drop it. |
2175 | 2164 |
2176 // if (!result.done) goto l_try; | 2165 // if (!result.done) goto l_try; |
2177 __ bind(&l_loop); | 2166 __ bind(&l_loop); |
2178 __ Move(load_receiver, rax); | 2167 __ Move(load_receiver, rax); |
2179 __ Push(load_receiver); // save result | 2168 __ Push(load_receiver); // save result |
2180 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2169 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
2181 if (FLAG_vector_ics) { | 2170 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2182 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2171 SmiFromSlot(expr->DoneFeedbackSlot())); |
2183 SmiFromSlot(expr->DoneFeedbackSlot())); | |
2184 } | |
2185 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done | 2172 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done |
2186 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2173 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2187 CallIC(bool_ic); | 2174 CallIC(bool_ic); |
2188 __ testp(result_register(), result_register()); | 2175 __ testp(result_register(), result_register()); |
2189 __ j(zero, &l_try); | 2176 __ j(zero, &l_try); |
2190 | 2177 |
2191 // result.value | 2178 // result.value |
2192 __ Pop(load_receiver); // result | 2179 __ Pop(load_receiver); // result |
2193 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | 2180 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" |
2194 if (FLAG_vector_ics) { | 2181 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2195 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2182 SmiFromSlot(expr->ValueFeedbackSlot())); |
2196 SmiFromSlot(expr->ValueFeedbackSlot())); | |
2197 } | |
2198 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax | 2183 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax |
2199 context()->DropAndPlug(2, rax); // drop iter and g | 2184 context()->DropAndPlug(2, rax); // drop iter and g |
2200 break; | 2185 break; |
2201 } | 2186 } |
2202 } | 2187 } |
2203 } | 2188 } |
2204 | 2189 |
2205 | 2190 |
2206 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2191 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
2207 Expression *value, | 2192 Expression *value, |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2326 rcx, rdx, kDontSaveFPRegs); | 2311 rcx, rdx, kDontSaveFPRegs); |
2327 } | 2312 } |
2328 | 2313 |
2329 | 2314 |
2330 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2315 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2331 SetSourcePosition(prop->position()); | 2316 SetSourcePosition(prop->position()); |
2332 Literal* key = prop->key()->AsLiteral(); | 2317 Literal* key = prop->key()->AsLiteral(); |
2333 DCHECK(!prop->IsSuperAccess()); | 2318 DCHECK(!prop->IsSuperAccess()); |
2334 | 2319 |
2335 __ Move(LoadDescriptor::NameRegister(), key->value()); | 2320 __ Move(LoadDescriptor::NameRegister(), key->value()); |
2336 if (FLAG_vector_ics) { | 2321 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2337 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2322 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2338 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2323 CallLoadIC(NOT_CONTEXTUAL); |
2339 CallLoadIC(NOT_CONTEXTUAL); | |
2340 } else { | |
2341 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | |
2342 } | |
2343 } | 2324 } |
2344 | 2325 |
2345 | 2326 |
2346 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2327 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2347 // Stack: receiver, home_object | 2328 // Stack: receiver, home_object |
2348 SetSourcePosition(prop->position()); | 2329 SetSourcePosition(prop->position()); |
2349 Literal* key = prop->key()->AsLiteral(); | 2330 Literal* key = prop->key()->AsLiteral(); |
2350 DCHECK(!key->value()->IsSmi()); | 2331 DCHECK(!key->value()->IsSmi()); |
2351 DCHECK(prop->IsSuperAccess()); | 2332 DCHECK(prop->IsSuperAccess()); |
2352 | 2333 |
2353 __ Push(key->value()); | 2334 __ Push(key->value()); |
2354 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2335 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2355 } | 2336 } |
2356 | 2337 |
2357 | 2338 |
2358 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2339 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2359 SetSourcePosition(prop->position()); | 2340 SetSourcePosition(prop->position()); |
2360 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2341 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2361 if (FLAG_vector_ics) { | 2342 __ Move(VectorLoadICDescriptor::SlotRegister(), |
2362 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2343 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2363 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2344 CallIC(ic); |
2364 CallIC(ic); | |
2365 } else { | |
2366 CallIC(ic, prop->PropertyFeedbackId()); | |
2367 } | |
2368 } | 2345 } |
2369 | 2346 |
2370 | 2347 |
2371 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2348 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2372 // Stack: receiver, home_object, key. | 2349 // Stack: receiver, home_object, key. |
2373 SetSourcePosition(prop->position()); | 2350 SetSourcePosition(prop->position()); |
2374 | 2351 |
2375 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2352 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2376 } | 2353 } |
2377 | 2354 |
(...skipping 2192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4570 | 4547 |
4571 | 4548 |
4572 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4549 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4573 // Push the builtins object as receiver. | 4550 // Push the builtins object as receiver. |
4574 __ movp(rax, GlobalObjectOperand()); | 4551 __ movp(rax, GlobalObjectOperand()); |
4575 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); | 4552 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); |
4576 | 4553 |
4577 // Load the function from the receiver. | 4554 // Load the function from the receiver. |
4578 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4555 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4579 __ Move(LoadDescriptor::NameRegister(), expr->name()); | 4556 __ Move(LoadDescriptor::NameRegister(), expr->name()); |
4580 if (FLAG_vector_ics) { | 4557 __ Move(VectorLoadICDescriptor::SlotRegister(), |
4581 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4558 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
4582 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4559 CallLoadIC(NOT_CONTEXTUAL); |
4583 CallLoadIC(NOT_CONTEXTUAL); | |
4584 } else { | |
4585 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4586 } | |
4587 } | 4560 } |
4588 | 4561 |
4589 | 4562 |
4590 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4563 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4591 ZoneList<Expression*>* args = expr->arguments(); | 4564 ZoneList<Expression*>* args = expr->arguments(); |
4592 int arg_count = args->length(); | 4565 int arg_count = args->length(); |
4593 | 4566 |
4594 // Record source position of the IC call. | 4567 // Record source position of the IC call. |
4595 SetSourcePosition(expr->position()); | 4568 SetSourcePosition(expr->position()); |
4596 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4569 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5011 | 4984 |
5012 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4985 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
5013 VariableProxy* proxy = expr->AsVariableProxy(); | 4986 VariableProxy* proxy = expr->AsVariableProxy(); |
5014 DCHECK(!context()->IsEffect()); | 4987 DCHECK(!context()->IsEffect()); |
5015 DCHECK(!context()->IsTest()); | 4988 DCHECK(!context()->IsTest()); |
5016 | 4989 |
5017 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4990 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
5018 Comment cmnt(masm_, "[ Global variable"); | 4991 Comment cmnt(masm_, "[ Global variable"); |
5019 __ Move(LoadDescriptor::NameRegister(), proxy->name()); | 4992 __ Move(LoadDescriptor::NameRegister(), proxy->name()); |
5020 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4993 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
5021 if (FLAG_vector_ics) { | 4994 __ Move(VectorLoadICDescriptor::SlotRegister(), |
5022 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4995 SmiFromSlot(proxy->VariableFeedbackSlot())); |
5023 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
5024 } | |
5025 // Use a regular load, not a contextual load, to avoid a reference | 4996 // Use a regular load, not a contextual load, to avoid a reference |
5026 // error. | 4997 // error. |
5027 CallLoadIC(NOT_CONTEXTUAL); | 4998 CallLoadIC(NOT_CONTEXTUAL); |
5028 PrepareForBailout(expr, TOS_REG); | 4999 PrepareForBailout(expr, TOS_REG); |
5029 context()->Plug(rax); | 5000 context()->Plug(rax); |
5030 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 5001 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
5031 Comment cmnt(masm_, "[ Lookup slot"); | 5002 Comment cmnt(masm_, "[ Lookup slot"); |
5032 Label done, slow; | 5003 Label done, slow; |
5033 | 5004 |
5034 // Generate code for loading from variables potentially shadowed | 5005 // Generate code for loading from variables potentially shadowed |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5395 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5366 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5396 Assembler::target_address_at(call_target_address, | 5367 Assembler::target_address_at(call_target_address, |
5397 unoptimized_code)); | 5368 unoptimized_code)); |
5398 return OSR_AFTER_STACK_CHECK; | 5369 return OSR_AFTER_STACK_CHECK; |
5399 } | 5370 } |
5400 | 5371 |
5401 | 5372 |
5402 } } // namespace v8::internal | 5373 } } // namespace v8::internal |
5403 | 5374 |
5404 #endif // V8_TARGET_ARCH_X64 | 5375 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |