OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1437 | 1437 |
1438 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { | 1438 void FullCodeGenerator::EmitVariableLoad(VariableProxy* proxy) { |
1439 // Record position before possible IC call. | 1439 // Record position before possible IC call. |
1440 SetSourcePosition(proxy->position()); | 1440 SetSourcePosition(proxy->position()); |
1441 Variable* var = proxy->var(); | 1441 Variable* var = proxy->var(); |
1442 | 1442 |
1443 // Three cases: global variables, lookup variables, and all other types of | 1443 // Three cases: global variables, lookup variables, and all other types of |
1444 // variables. | 1444 // variables. |
1445 switch (var->location()) { | 1445 switch (var->location()) { |
1446 case Variable::UNALLOCATED: { | 1446 case Variable::UNALLOCATED: { |
1447 Comment cmnt(masm_, "Global variable"); | 1447 Comment cmnt(masm_, "[ Global variable"); |
1448 // Use inline caching. Variable name is passed in rcx and the global | 1448 // Use inline caching. Variable name is passed in rcx and the global |
1449 // object on the stack. | 1449 // object on the stack. |
1450 __ Move(rcx, var->name()); | 1450 __ Move(rcx, var->name()); |
1451 __ movp(rax, GlobalObjectOperand()); | 1451 __ movp(rax, GlobalObjectOperand()); |
1452 CallLoadIC(CONTEXTUAL); | 1452 CallLoadIC(CONTEXTUAL); |
1453 context()->Plug(rax); | 1453 context()->Plug(rax); |
1454 break; | 1454 break; |
1455 } | 1455 } |
1456 | 1456 |
1457 case Variable::PARAMETER: | 1457 case Variable::PARAMETER: |
1458 case Variable::LOCAL: | 1458 case Variable::LOCAL: |
1459 case Variable::CONTEXT: { | 1459 case Variable::CONTEXT: { |
1460 Comment cmnt(masm_, var->IsContextSlot() ? "Context slot" : "Stack slot"); | 1460 Comment cmnt(masm_, var->IsContextSlot() ? "[ Context slot" |
| 1461 : "[ Stack slot"); |
1461 if (var->binding_needs_init()) { | 1462 if (var->binding_needs_init()) { |
1462 // var->scope() may be NULL when the proxy is located in eval code and | 1463 // var->scope() may be NULL when the proxy is located in eval code and |
1463 // refers to a potential outside binding. Currently those bindings are | 1464 // refers to a potential outside binding. Currently those bindings are |
1464 // always looked up dynamically, i.e. in that case | 1465 // always looked up dynamically, i.e. in that case |
1465 // var->location() == LOOKUP. | 1466 // var->location() == LOOKUP. |
1466 // always holds. | 1467 // always holds. |
1467 ASSERT(var->scope() != NULL); | 1468 ASSERT(var->scope() != NULL); |
1468 | 1469 |
1469 // Check if the binding really needs an initialization check. The check | 1470 // Check if the binding really needs an initialization check. The check |
1470 // can be skipped in the following situation: we have a LET or CONST | 1471 // can be skipped in the following situation: we have a LET or CONST |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 __ bind(&done); | 1513 __ bind(&done); |
1513 context()->Plug(rax); | 1514 context()->Plug(rax); |
1514 break; | 1515 break; |
1515 } | 1516 } |
1516 } | 1517 } |
1517 context()->Plug(var); | 1518 context()->Plug(var); |
1518 break; | 1519 break; |
1519 } | 1520 } |
1520 | 1521 |
1521 case Variable::LOOKUP: { | 1522 case Variable::LOOKUP: { |
| 1523 Comment cmnt(masm_, "[ Lookup slot"); |
1522 Label done, slow; | 1524 Label done, slow; |
1523 // Generate code for loading from variables potentially shadowed | 1525 // Generate code for loading from variables potentially shadowed |
1524 // by eval-introduced variables. | 1526 // by eval-introduced variables. |
1525 EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done); | 1527 EmitDynamicLookupFastCase(var, NOT_INSIDE_TYPEOF, &slow, &done); |
1526 __ bind(&slow); | 1528 __ bind(&slow); |
1527 Comment cmnt(masm_, "Lookup slot"); | |
1528 __ push(rsi); // Context. | 1529 __ push(rsi); // Context. |
1529 __ Push(var->name()); | 1530 __ Push(var->name()); |
1530 __ CallRuntime(Runtime::kLoadContextSlot, 2); | 1531 __ CallRuntime(Runtime::kLoadContextSlot, 2); |
1531 __ bind(&done); | 1532 __ bind(&done); |
1532 context()->Plug(rax); | 1533 context()->Plug(rax); |
1533 break; | 1534 break; |
1534 } | 1535 } |
1535 } | 1536 } |
1536 } | 1537 } |
1537 | 1538 |
(...skipping 2934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4472 } | 4473 } |
4473 } | 4474 } |
4474 | 4475 |
4475 | 4476 |
4476 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4477 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4477 VariableProxy* proxy = expr->AsVariableProxy(); | 4478 VariableProxy* proxy = expr->AsVariableProxy(); |
4478 ASSERT(!context()->IsEffect()); | 4479 ASSERT(!context()->IsEffect()); |
4479 ASSERT(!context()->IsTest()); | 4480 ASSERT(!context()->IsTest()); |
4480 | 4481 |
4481 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4482 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4482 Comment cmnt(masm_, "Global variable"); | 4483 Comment cmnt(masm_, "[ Global variable"); |
4483 __ Move(rcx, proxy->name()); | 4484 __ Move(rcx, proxy->name()); |
4484 __ movp(rax, GlobalObjectOperand()); | 4485 __ movp(rax, GlobalObjectOperand()); |
4485 // Use a regular load, not a contextual load, to avoid a reference | 4486 // Use a regular load, not a contextual load, to avoid a reference |
4486 // error. | 4487 // error. |
4487 CallLoadIC(NOT_CONTEXTUAL); | 4488 CallLoadIC(NOT_CONTEXTUAL); |
4488 PrepareForBailout(expr, TOS_REG); | 4489 PrepareForBailout(expr, TOS_REG); |
4489 context()->Plug(rax); | 4490 context()->Plug(rax); |
4490 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4491 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
| 4492 Comment cmnt(masm_, "[ Lookup slot"); |
4491 Label done, slow; | 4493 Label done, slow; |
4492 | 4494 |
4493 // Generate code for loading from variables potentially shadowed | 4495 // Generate code for loading from variables potentially shadowed |
4494 // by eval-introduced variables. | 4496 // by eval-introduced variables. |
4495 EmitDynamicLookupFastCase(proxy->var(), INSIDE_TYPEOF, &slow, &done); | 4497 EmitDynamicLookupFastCase(proxy->var(), INSIDE_TYPEOF, &slow, &done); |
4496 | 4498 |
4497 __ bind(&slow); | 4499 __ bind(&slow); |
4498 __ push(rsi); | 4500 __ push(rsi); |
4499 __ Push(proxy->name()); | 4501 __ Push(proxy->name()); |
4500 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); | 4502 __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4906 | 4908 |
4907 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4909 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4908 Assembler::target_address_at(call_target_address)); | 4910 Assembler::target_address_at(call_target_address)); |
4909 return OSR_AFTER_STACK_CHECK; | 4911 return OSR_AFTER_STACK_CHECK; |
4910 } | 4912 } |
4911 | 4913 |
4912 | 4914 |
4913 } } // namespace v8::internal | 4915 } } // namespace v8::internal |
4914 | 4916 |
4915 #endif // V8_TARGET_ARCH_X64 | 4917 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |