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 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1297 __ Move(LoadDescriptor::SlotRegister(), |
1298 SmiFromSlot(expr->HomeObjectFeedbackSlot())); | 1298 SmiFromSlot(expr->HomeObjectFeedbackSlot())); |
1299 CallLoadIC(NOT_CONTEXTUAL); | 1299 CallLoadIC(NOT_CONTEXTUAL); |
1300 | 1300 |
1301 __ Cmp(rax, isolate()->factory()->undefined_value()); | 1301 __ Cmp(rax, isolate()->factory()->undefined_value()); |
1302 Label done; | 1302 Label done; |
1303 __ j(not_equal, &done); | 1303 __ j(not_equal, &done); |
1304 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1304 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1305 __ bind(&done); | 1305 __ bind(&done); |
1306 } | 1306 } |
1307 | 1307 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 // Load next context in chain. | 1365 // Load next context in chain. |
1366 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); | 1366 __ movp(temp, ContextOperand(temp, Context::PREVIOUS_INDEX)); |
1367 __ jmp(&next); | 1367 __ jmp(&next); |
1368 __ bind(&fast); | 1368 __ bind(&fast); |
1369 } | 1369 } |
1370 | 1370 |
1371 // 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 |
1372 // load IC call. | 1372 // load IC call. |
1373 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1373 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1374 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); | 1374 __ Move(LoadDescriptor::NameRegister(), proxy->var()->name()); |
1375 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1375 __ Move(LoadDescriptor::SlotRegister(), |
1376 SmiFromSlot(proxy->VariableFeedbackSlot())); | 1376 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1377 | 1377 |
1378 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) | 1378 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) |
1379 ? NOT_CONTEXTUAL | 1379 ? NOT_CONTEXTUAL |
1380 : CONTEXTUAL; | 1380 : CONTEXTUAL; |
1381 CallLoadIC(mode); | 1381 CallLoadIC(mode); |
1382 } | 1382 } |
1383 | 1383 |
1384 | 1384 |
1385 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1385 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1450 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1451 Variable* var = proxy->var(); | 1451 Variable* var = proxy->var(); |
1452 | 1452 |
1453 // Three cases: global variables, lookup variables, and all other types of | 1453 // Three cases: global variables, lookup variables, and all other types of |
1454 // variables. | 1454 // variables. |
1455 switch (var->location()) { | 1455 switch (var->location()) { |
1456 case Variable::UNALLOCATED: { | 1456 case Variable::UNALLOCATED: { |
1457 Comment cmnt(masm_, "[ Global variable"); | 1457 Comment cmnt(masm_, "[ Global variable"); |
1458 __ Move(LoadDescriptor::NameRegister(), var->name()); | 1458 __ Move(LoadDescriptor::NameRegister(), var->name()); |
1459 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 1459 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
1460 __ Move(VectorLoadICDescriptor::SlotRegister(), | 1460 __ Move(LoadDescriptor::SlotRegister(), |
1461 SmiFromSlot(proxy->VariableFeedbackSlot())); | 1461 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1462 CallGlobalLoadIC(var->name()); | 1462 CallGlobalLoadIC(var->name()); |
1463 context()->Plug(rax); | 1463 context()->Plug(rax); |
1464 break; | 1464 break; |
1465 } | 1465 } |
1466 | 1466 |
1467 case Variable::PARAMETER: | 1467 case Variable::PARAMETER: |
1468 case Variable::LOCAL: | 1468 case Variable::LOCAL: |
1469 case Variable::CONTEXT: { | 1469 case Variable::CONTEXT: { |
1470 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" | 1470 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2143 __ bind(&l_next); | 2143 __ bind(&l_next); |
2144 | 2144 |
2145 __ LoadRoot(load_name, Heap::knext_stringRootIndex); | 2145 __ LoadRoot(load_name, Heap::knext_stringRootIndex); |
2146 __ Push(load_name); // "next" | 2146 __ Push(load_name); // "next" |
2147 __ Push(Operand(rsp, 2 * kPointerSize)); // iter | 2147 __ Push(Operand(rsp, 2 * kPointerSize)); // iter |
2148 __ Push(rax); // received | 2148 __ Push(rax); // received |
2149 | 2149 |
2150 // result = receiver[f](arg); | 2150 // result = receiver[f](arg); |
2151 __ bind(&l_call); | 2151 __ bind(&l_call); |
2152 __ movp(load_receiver, Operand(rsp, kPointerSize)); | 2152 __ movp(load_receiver, Operand(rsp, kPointerSize)); |
2153 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2153 __ Move(LoadDescriptor::SlotRegister(), |
2154 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | 2154 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
2155 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2155 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2156 CallIC(ic, TypeFeedbackId::None()); | 2156 CallIC(ic, TypeFeedbackId::None()); |
2157 __ movp(rdi, rax); | 2157 __ movp(rdi, rax); |
2158 __ movp(Operand(rsp, 2 * kPointerSize), rdi); | 2158 __ movp(Operand(rsp, 2 * kPointerSize), rdi); |
2159 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 2159 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
2160 __ CallStub(&stub); | 2160 __ CallStub(&stub); |
2161 | 2161 |
2162 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); | 2162 __ movp(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
2163 __ Drop(1); // The function is still on the stack; drop it. | 2163 __ Drop(1); // The function is still on the stack; drop it. |
2164 | 2164 |
2165 // if (!result.done) goto l_try; | 2165 // if (!result.done) goto l_try; |
2166 __ bind(&l_loop); | 2166 __ bind(&l_loop); |
2167 __ Move(load_receiver, rax); | 2167 __ Move(load_receiver, rax); |
2168 __ Push(load_receiver); // save result | 2168 __ Push(load_receiver); // save result |
2169 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 2169 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
2170 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2170 __ Move(LoadDescriptor::SlotRegister(), |
2171 SmiFromSlot(expr->DoneFeedbackSlot())); | 2171 SmiFromSlot(expr->DoneFeedbackSlot())); |
2172 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done | 2172 CallLoadIC(NOT_CONTEXTUAL); // rax=result.done |
2173 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 2173 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
2174 CallIC(bool_ic); | 2174 CallIC(bool_ic); |
2175 __ testp(result_register(), result_register()); | 2175 __ testp(result_register(), result_register()); |
2176 __ j(zero, &l_try); | 2176 __ j(zero, &l_try); |
2177 | 2177 |
2178 // result.value | 2178 // result.value |
2179 __ Pop(load_receiver); // result | 2179 __ Pop(load_receiver); // result |
2180 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | 2180 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" |
2181 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2181 __ Move(LoadDescriptor::SlotRegister(), |
2182 SmiFromSlot(expr->ValueFeedbackSlot())); | 2182 SmiFromSlot(expr->ValueFeedbackSlot())); |
2183 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax | 2183 CallLoadIC(NOT_CONTEXTUAL); // result.value in rax |
2184 context()->DropAndPlug(2, rax); // drop iter and g | 2184 context()->DropAndPlug(2, rax); // drop iter and g |
2185 break; | 2185 break; |
2186 } | 2186 } |
2187 } | 2187 } |
2188 } | 2188 } |
2189 | 2189 |
2190 | 2190 |
2191 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 2191 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 rcx, rdx, kDontSaveFPRegs); | 2311 rcx, rdx, kDontSaveFPRegs); |
2312 } | 2312 } |
2313 | 2313 |
2314 | 2314 |
2315 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2315 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2316 SetSourcePosition(prop->position()); | 2316 SetSourcePosition(prop->position()); |
2317 Literal* key = prop->key()->AsLiteral(); | 2317 Literal* key = prop->key()->AsLiteral(); |
2318 DCHECK(!prop->IsSuperAccess()); | 2318 DCHECK(!prop->IsSuperAccess()); |
2319 | 2319 |
2320 __ Move(LoadDescriptor::NameRegister(), key->value()); | 2320 __ Move(LoadDescriptor::NameRegister(), key->value()); |
2321 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2321 __ Move(LoadDescriptor::SlotRegister(), |
2322 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2322 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2323 CallLoadIC(NOT_CONTEXTUAL); | 2323 CallLoadIC(NOT_CONTEXTUAL); |
2324 } | 2324 } |
2325 | 2325 |
2326 | 2326 |
2327 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2327 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2328 // Stack: receiver, home_object | 2328 // Stack: receiver, home_object |
2329 SetSourcePosition(prop->position()); | 2329 SetSourcePosition(prop->position()); |
2330 Literal* key = prop->key()->AsLiteral(); | 2330 Literal* key = prop->key()->AsLiteral(); |
2331 DCHECK(!key->value()->IsSmi()); | 2331 DCHECK(!key->value()->IsSmi()); |
2332 DCHECK(prop->IsSuperAccess()); | 2332 DCHECK(prop->IsSuperAccess()); |
2333 | 2333 |
2334 __ Push(key->value()); | 2334 __ Push(key->value()); |
2335 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2335 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2336 } | 2336 } |
2337 | 2337 |
2338 | 2338 |
2339 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2339 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2340 SetSourcePosition(prop->position()); | 2340 SetSourcePosition(prop->position()); |
2341 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2341 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2342 __ Move(VectorLoadICDescriptor::SlotRegister(), | 2342 __ Move(LoadDescriptor::SlotRegister(), |
2343 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2343 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2344 CallIC(ic); | 2344 CallIC(ic); |
2345 } | 2345 } |
2346 | 2346 |
2347 | 2347 |
2348 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2348 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2349 // Stack: receiver, home_object, key. | 2349 // Stack: receiver, home_object, key. |
2350 SetSourcePosition(prop->position()); | 2350 SetSourcePosition(prop->position()); |
2351 | 2351 |
2352 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2352 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4547 | 4547 |
4548 | 4548 |
4549 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4549 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4550 // Push the builtins object as receiver. | 4550 // Push the builtins object as receiver. |
4551 __ movp(rax, GlobalObjectOperand()); | 4551 __ movp(rax, GlobalObjectOperand()); |
4552 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); | 4552 __ Push(FieldOperand(rax, GlobalObject::kBuiltinsOffset)); |
4553 | 4553 |
4554 // Load the function from the receiver. | 4554 // Load the function from the receiver. |
4555 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); | 4555 __ movp(LoadDescriptor::ReceiverRegister(), Operand(rsp, 0)); |
4556 __ Move(LoadDescriptor::NameRegister(), expr->name()); | 4556 __ Move(LoadDescriptor::NameRegister(), expr->name()); |
4557 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4557 __ Move(LoadDescriptor::SlotRegister(), |
4558 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4558 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
4559 CallLoadIC(NOT_CONTEXTUAL); | 4559 CallLoadIC(NOT_CONTEXTUAL); |
4560 } | 4560 } |
4561 | 4561 |
4562 | 4562 |
4563 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4563 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4564 ZoneList<Expression*>* args = expr->arguments(); | 4564 ZoneList<Expression*>* args = expr->arguments(); |
4565 int arg_count = args->length(); | 4565 int arg_count = args->length(); |
4566 | 4566 |
4567 // Record source position of the IC call. | 4567 // Record source position of the IC call. |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4984 | 4984 |
4985 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4985 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4986 VariableProxy* proxy = expr->AsVariableProxy(); | 4986 VariableProxy* proxy = expr->AsVariableProxy(); |
4987 DCHECK(!context()->IsEffect()); | 4987 DCHECK(!context()->IsEffect()); |
4988 DCHECK(!context()->IsTest()); | 4988 DCHECK(!context()->IsTest()); |
4989 | 4989 |
4990 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4990 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4991 Comment cmnt(masm_, "[ Global variable"); | 4991 Comment cmnt(masm_, "[ Global variable"); |
4992 __ Move(LoadDescriptor::NameRegister(), proxy->name()); | 4992 __ Move(LoadDescriptor::NameRegister(), proxy->name()); |
4993 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); | 4993 __ movp(LoadDescriptor::ReceiverRegister(), GlobalObjectOperand()); |
4994 __ Move(VectorLoadICDescriptor::SlotRegister(), | 4994 __ Move(LoadDescriptor::SlotRegister(), |
4995 SmiFromSlot(proxy->VariableFeedbackSlot())); | 4995 SmiFromSlot(proxy->VariableFeedbackSlot())); |
4996 // 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 |
4997 // error. | 4997 // error. |
4998 CallLoadIC(NOT_CONTEXTUAL); | 4998 CallLoadIC(NOT_CONTEXTUAL); |
4999 PrepareForBailout(expr, TOS_REG); | 4999 PrepareForBailout(expr, TOS_REG); |
5000 context()->Plug(rax); | 5000 context()->Plug(rax); |
5001 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 5001 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
5002 Comment cmnt(masm_, "[ Lookup slot"); | 5002 Comment cmnt(masm_, "[ Lookup slot"); |
5003 Label done, slow; | 5003 Label done, slow; |
5004 | 5004 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5367 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 5367 DCHECK_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
5368 Assembler::target_address_at(call_target_address, | 5368 Assembler::target_address_at(call_target_address, |
5369 unoptimized_code)); | 5369 unoptimized_code)); |
5370 return OSR_AFTER_STACK_CHECK; | 5370 return OSR_AFTER_STACK_CHECK; |
5371 } | 5371 } |
5372 | 5372 |
5373 | 5373 |
5374 } } // namespace v8::internal | 5374 } } // namespace v8::internal |
5375 | 5375 |
5376 #endif // V8_TARGET_ARCH_X64 | 5376 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |