OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
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 1304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 | 1315 |
1316 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { | 1316 void FullCodeGenerator::EmitLoadHomeObject(SuperReference* expr) { |
1317 Comment cnmt(masm_, "[ SuperReference "); | 1317 Comment cnmt(masm_, "[ SuperReference "); |
1318 | 1318 |
1319 __ ldr(LoadDescriptor::ReceiverRegister(), | 1319 __ ldr(LoadDescriptor::ReceiverRegister(), |
1320 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 1320 MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
1321 | 1321 |
1322 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); | 1322 Handle<Symbol> home_object_symbol(isolate()->heap()->home_object_symbol()); |
1323 __ Mov(LoadDescriptor::NameRegister(), Operand(home_object_symbol)); | 1323 __ Mov(LoadDescriptor::NameRegister(), Operand(home_object_symbol)); |
1324 | 1324 |
1325 if (FLAG_vector_ics) { | 1325 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
1326 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 1326 SmiFromSlot(expr->HomeObjectFeedbackSlot())); |
1327 SmiFromSlot(expr->HomeObjectFeedbackSlot())); | 1327 CallLoadIC(NOT_CONTEXTUAL); |
1328 CallLoadIC(NOT_CONTEXTUAL); | |
1329 } else { | |
1330 CallLoadIC(NOT_CONTEXTUAL, expr->HomeObjectFeedbackId()); | |
1331 } | |
1332 | 1328 |
1333 __ Mov(x10, Operand(isolate()->factory()->undefined_value())); | 1329 __ Mov(x10, Operand(isolate()->factory()->undefined_value())); |
1334 __ cmp(x0, x10); | 1330 __ cmp(x0, x10); |
1335 Label done; | 1331 Label done; |
1336 __ b(&done, ne); | 1332 __ b(&done, ne); |
1337 __ CallRuntime(Runtime::kThrowNonMethodError, 0); | 1333 __ CallRuntime(Runtime::kThrowNonMethodError, 0); |
1338 __ bind(&done); | 1334 __ bind(&done); |
1339 } | 1335 } |
1340 | 1336 |
1341 | 1337 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1389 __ Ldr(temp, ContextMemOperand(next, Context::EXTENSION_INDEX)); | 1385 __ Ldr(temp, ContextMemOperand(next, Context::EXTENSION_INDEX)); |
1390 __ Cbnz(temp, slow); | 1386 __ Cbnz(temp, slow); |
1391 // Load next context in chain. | 1387 // Load next context in chain. |
1392 __ Ldr(next, ContextMemOperand(next, Context::PREVIOUS_INDEX)); | 1388 __ Ldr(next, ContextMemOperand(next, Context::PREVIOUS_INDEX)); |
1393 __ B(&loop); | 1389 __ B(&loop); |
1394 __ Bind(&fast); | 1390 __ Bind(&fast); |
1395 } | 1391 } |
1396 | 1392 |
1397 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); | 1393 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
1398 __ Mov(LoadDescriptor::NameRegister(), Operand(proxy->var()->name())); | 1394 __ Mov(LoadDescriptor::NameRegister(), Operand(proxy->var()->name())); |
1399 if (FLAG_vector_ics) { | 1395 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
1400 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 1396 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1401 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1402 } | |
1403 | 1397 |
1404 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) ? NOT_CONTEXTUAL | 1398 ContextualMode mode = (typeof_state == INSIDE_TYPEOF) ? NOT_CONTEXTUAL |
1405 : CONTEXTUAL; | 1399 : CONTEXTUAL; |
1406 CallLoadIC(mode); | 1400 CallLoadIC(mode); |
1407 } | 1401 } |
1408 | 1402 |
1409 | 1403 |
1410 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, | 1404 MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(Variable* var, |
1411 Label* slow) { | 1405 Label* slow) { |
1412 DCHECK(var->IsContextSlot()); | 1406 DCHECK(var->IsContextSlot()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1475 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); | 1469 PrepareForBailoutForId(proxy->BeforeId(), NO_REGISTERS); |
1476 Variable* var = proxy->var(); | 1470 Variable* var = proxy->var(); |
1477 | 1471 |
1478 // Three cases: global variables, lookup variables, and all other types of | 1472 // Three cases: global variables, lookup variables, and all other types of |
1479 // variables. | 1473 // variables. |
1480 switch (var->location()) { | 1474 switch (var->location()) { |
1481 case Variable::UNALLOCATED: { | 1475 case Variable::UNALLOCATED: { |
1482 Comment cmnt(masm_, "Global variable"); | 1476 Comment cmnt(masm_, "Global variable"); |
1483 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); | 1477 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
1484 __ Mov(LoadDescriptor::NameRegister(), Operand(var->name())); | 1478 __ Mov(LoadDescriptor::NameRegister(), Operand(var->name())); |
1485 if (FLAG_vector_ics) { | 1479 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
1486 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 1480 SmiFromSlot(proxy->VariableFeedbackSlot())); |
1487 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
1488 } | |
1489 CallGlobalLoadIC(var->name()); | 1481 CallGlobalLoadIC(var->name()); |
1490 context()->Plug(x0); | 1482 context()->Plug(x0); |
1491 break; | 1483 break; |
1492 } | 1484 } |
1493 | 1485 |
1494 case Variable::PARAMETER: | 1486 case Variable::PARAMETER: |
1495 case Variable::LOCAL: | 1487 case Variable::LOCAL: |
1496 case Variable::CONTEXT: { | 1488 case Variable::CONTEXT: { |
1497 Comment cmnt(masm_, var->IsContextSlot() | 1489 Comment cmnt(masm_, var->IsContextSlot() |
1498 ? "Context variable" | 1490 ? "Context variable" |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2051 } | 2043 } |
2052 } | 2044 } |
2053 | 2045 |
2054 | 2046 |
2055 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { | 2047 void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) { |
2056 SetSourcePosition(prop->position()); | 2048 SetSourcePosition(prop->position()); |
2057 Literal* key = prop->key()->AsLiteral(); | 2049 Literal* key = prop->key()->AsLiteral(); |
2058 DCHECK(!prop->IsSuperAccess()); | 2050 DCHECK(!prop->IsSuperAccess()); |
2059 | 2051 |
2060 __ Mov(LoadDescriptor::NameRegister(), Operand(key->value())); | 2052 __ Mov(LoadDescriptor::NameRegister(), Operand(key->value())); |
2061 if (FLAG_vector_ics) { | 2053 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
2062 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 2054 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2063 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2055 CallLoadIC(NOT_CONTEXTUAL); |
2064 CallLoadIC(NOT_CONTEXTUAL); | |
2065 } else { | |
2066 CallLoadIC(NOT_CONTEXTUAL, prop->PropertyFeedbackId()); | |
2067 } | |
2068 } | 2056 } |
2069 | 2057 |
2070 | 2058 |
2071 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { | 2059 void FullCodeGenerator::EmitNamedSuperPropertyLoad(Property* prop) { |
2072 // Stack: receiver, home_object. | 2060 // Stack: receiver, home_object. |
2073 SetSourcePosition(prop->position()); | 2061 SetSourcePosition(prop->position()); |
2074 Literal* key = prop->key()->AsLiteral(); | 2062 Literal* key = prop->key()->AsLiteral(); |
2075 DCHECK(!key->value()->IsSmi()); | 2063 DCHECK(!key->value()->IsSmi()); |
2076 DCHECK(prop->IsSuperAccess()); | 2064 DCHECK(prop->IsSuperAccess()); |
2077 | 2065 |
2078 __ Push(key->value()); | 2066 __ Push(key->value()); |
2079 __ CallRuntime(Runtime::kLoadFromSuper, 3); | 2067 __ CallRuntime(Runtime::kLoadFromSuper, 3); |
2080 } | 2068 } |
2081 | 2069 |
2082 | 2070 |
2083 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { | 2071 void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) { |
2084 SetSourcePosition(prop->position()); | 2072 SetSourcePosition(prop->position()); |
2085 // Call keyed load IC. It has arguments key and receiver in x0 and x1. | 2073 // Call keyed load IC. It has arguments key and receiver in x0 and x1. |
2086 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 2074 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
2087 if (FLAG_vector_ics) { | 2075 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
2088 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 2076 SmiFromSlot(prop->PropertyFeedbackSlot())); |
2089 SmiFromSlot(prop->PropertyFeedbackSlot())); | 2077 CallIC(ic); |
2090 CallIC(ic); | |
2091 } else { | |
2092 CallIC(ic, prop->PropertyFeedbackId()); | |
2093 } | |
2094 } | 2078 } |
2095 | 2079 |
2096 | 2080 |
2097 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { | 2081 void FullCodeGenerator::EmitKeyedSuperPropertyLoad(Property* prop) { |
2098 // Stack: receiver, home_object, key. | 2082 // Stack: receiver, home_object, key. |
2099 SetSourcePosition(prop->position()); | 2083 SetSourcePosition(prop->position()); |
2100 | 2084 |
2101 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); | 2085 __ CallRuntime(Runtime::kLoadKeyedFromSuper, 3); |
2102 } | 2086 } |
2103 | 2087 |
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4310 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { | 4294 void FullCodeGenerator::EmitLoadJSRuntimeFunction(CallRuntime* expr) { |
4311 // Push the builtins object as the receiver. | 4295 // Push the builtins object as the receiver. |
4312 __ Ldr(x10, GlobalObjectMemOperand()); | 4296 __ Ldr(x10, GlobalObjectMemOperand()); |
4313 __ Ldr(LoadDescriptor::ReceiverRegister(), | 4297 __ Ldr(LoadDescriptor::ReceiverRegister(), |
4314 FieldMemOperand(x10, GlobalObject::kBuiltinsOffset)); | 4298 FieldMemOperand(x10, GlobalObject::kBuiltinsOffset)); |
4315 __ Push(LoadDescriptor::ReceiverRegister()); | 4299 __ Push(LoadDescriptor::ReceiverRegister()); |
4316 | 4300 |
4317 // Load the function from the receiver. | 4301 // Load the function from the receiver. |
4318 Handle<String> name = expr->name(); | 4302 Handle<String> name = expr->name(); |
4319 __ Mov(LoadDescriptor::NameRegister(), Operand(name)); | 4303 __ Mov(LoadDescriptor::NameRegister(), Operand(name)); |
4320 if (FLAG_vector_ics) { | 4304 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
4321 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 4305 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); |
4322 SmiFromSlot(expr->CallRuntimeFeedbackSlot())); | 4306 CallLoadIC(NOT_CONTEXTUAL); |
4323 CallLoadIC(NOT_CONTEXTUAL); | |
4324 } else { | |
4325 CallLoadIC(NOT_CONTEXTUAL, expr->CallRuntimeFeedbackId()); | |
4326 } | |
4327 } | 4307 } |
4328 | 4308 |
4329 | 4309 |
4330 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { | 4310 void FullCodeGenerator::EmitCallJSRuntimeFunction(CallRuntime* expr) { |
4331 ZoneList<Expression*>* args = expr->arguments(); | 4311 ZoneList<Expression*>* args = expr->arguments(); |
4332 int arg_count = args->length(); | 4312 int arg_count = args->length(); |
4333 | 4313 |
4334 // Record source position of the IC call. | 4314 // Record source position of the IC call. |
4335 SetSourcePosition(expr->position()); | 4315 SetSourcePosition(expr->position()); |
4336 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); | 4316 CallFunctionStub stub(isolate(), arg_count, NO_CALL_FUNCTION_FLAGS); |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4744 | 4724 |
4745 | 4725 |
4746 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { | 4726 void FullCodeGenerator::VisitForTypeofValue(Expression* expr) { |
4747 DCHECK(!context()->IsEffect()); | 4727 DCHECK(!context()->IsEffect()); |
4748 DCHECK(!context()->IsTest()); | 4728 DCHECK(!context()->IsTest()); |
4749 VariableProxy* proxy = expr->AsVariableProxy(); | 4729 VariableProxy* proxy = expr->AsVariableProxy(); |
4750 if (proxy != NULL && proxy->var()->IsUnallocated()) { | 4730 if (proxy != NULL && proxy->var()->IsUnallocated()) { |
4751 Comment cmnt(masm_, "Global variable"); | 4731 Comment cmnt(masm_, "Global variable"); |
4752 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); | 4732 __ Ldr(LoadDescriptor::ReceiverRegister(), GlobalObjectMemOperand()); |
4753 __ Mov(LoadDescriptor::NameRegister(), Operand(proxy->name())); | 4733 __ Mov(LoadDescriptor::NameRegister(), Operand(proxy->name())); |
4754 if (FLAG_vector_ics) { | 4734 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
4755 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 4735 SmiFromSlot(proxy->VariableFeedbackSlot())); |
4756 SmiFromSlot(proxy->VariableFeedbackSlot())); | |
4757 } | |
4758 // Use a regular load, not a contextual load, to avoid a reference | 4736 // Use a regular load, not a contextual load, to avoid a reference |
4759 // error. | 4737 // error. |
4760 CallLoadIC(NOT_CONTEXTUAL); | 4738 CallLoadIC(NOT_CONTEXTUAL); |
4761 PrepareForBailout(expr, TOS_REG); | 4739 PrepareForBailout(expr, TOS_REG); |
4762 context()->Plug(x0); | 4740 context()->Plug(x0); |
4763 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { | 4741 } else if (proxy != NULL && proxy->var()->IsLookupSlot()) { |
4764 Label done, slow; | 4742 Label done, slow; |
4765 | 4743 |
4766 // Generate code for loading from variables potentially shadowed | 4744 // Generate code for loading from variables potentially shadowed |
4767 // by eval-introduced variables. | 4745 // by eval-introduced variables. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5100 __ Bind(&l_next); | 5078 __ Bind(&l_next); |
5101 | 5079 |
5102 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" | 5080 __ LoadRoot(load_name, Heap::knext_stringRootIndex); // "next" |
5103 __ Peek(x3, 1 * kPointerSize); // iter | 5081 __ Peek(x3, 1 * kPointerSize); // iter |
5104 __ Push(load_name, x3, x0); // "next", iter, received | 5082 __ Push(load_name, x3, x0); // "next", iter, received |
5105 | 5083 |
5106 // result = receiver[f](arg); | 5084 // result = receiver[f](arg); |
5107 __ Bind(&l_call); | 5085 __ Bind(&l_call); |
5108 __ Peek(load_receiver, 1 * kPointerSize); | 5086 __ Peek(load_receiver, 1 * kPointerSize); |
5109 __ Peek(load_name, 2 * kPointerSize); | 5087 __ Peek(load_name, 2 * kPointerSize); |
5110 if (FLAG_vector_ics) { | 5088 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
5111 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 5089 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); |
5112 SmiFromSlot(expr->KeyedLoadFeedbackSlot())); | |
5113 } | |
5114 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); | 5090 Handle<Code> ic = CodeFactory::KeyedLoadIC(isolate()).code(); |
5115 CallIC(ic, TypeFeedbackId::None()); | 5091 CallIC(ic, TypeFeedbackId::None()); |
5116 __ Mov(x1, x0); | 5092 __ Mov(x1, x0); |
5117 __ Poke(x1, 2 * kPointerSize); | 5093 __ Poke(x1, 2 * kPointerSize); |
5118 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); | 5094 CallFunctionStub stub(isolate(), 1, CALL_AS_METHOD); |
5119 __ CallStub(&stub); | 5095 __ CallStub(&stub); |
5120 | 5096 |
5121 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 5097 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
5122 __ Drop(1); // The function is still on the stack; drop it. | 5098 __ Drop(1); // The function is still on the stack; drop it. |
5123 | 5099 |
5124 // if (!result.done) goto l_try; | 5100 // if (!result.done) goto l_try; |
5125 __ Bind(&l_loop); | 5101 __ Bind(&l_loop); |
5126 __ Move(load_receiver, x0); | 5102 __ Move(load_receiver, x0); |
5127 | 5103 |
5128 __ Push(load_receiver); // save result | 5104 __ Push(load_receiver); // save result |
5129 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" | 5105 __ LoadRoot(load_name, Heap::kdone_stringRootIndex); // "done" |
5130 if (FLAG_vector_ics) { | 5106 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
5131 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 5107 SmiFromSlot(expr->DoneFeedbackSlot())); |
5132 SmiFromSlot(expr->DoneFeedbackSlot())); | |
5133 } | |
5134 CallLoadIC(NOT_CONTEXTUAL); // x0=result.done | 5108 CallLoadIC(NOT_CONTEXTUAL); // x0=result.done |
5135 // The ToBooleanStub argument (result.done) is in x0. | 5109 // The ToBooleanStub argument (result.done) is in x0. |
5136 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); | 5110 Handle<Code> bool_ic = ToBooleanStub::GetUninitialized(isolate()); |
5137 CallIC(bool_ic); | 5111 CallIC(bool_ic); |
5138 __ Cbz(x0, &l_try); | 5112 __ Cbz(x0, &l_try); |
5139 | 5113 |
5140 // result.value | 5114 // result.value |
5141 __ Pop(load_receiver); // result | 5115 __ Pop(load_receiver); // result |
5142 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" | 5116 __ LoadRoot(load_name, Heap::kvalue_stringRootIndex); // "value" |
5143 if (FLAG_vector_ics) { | 5117 __ Mov(VectorLoadICDescriptor::SlotRegister(), |
5144 __ Mov(VectorLoadICDescriptor::SlotRegister(), | 5118 SmiFromSlot(expr->ValueFeedbackSlot())); |
5145 SmiFromSlot(expr->ValueFeedbackSlot())); | |
5146 } | |
5147 CallLoadIC(NOT_CONTEXTUAL); // x0=result.value | 5119 CallLoadIC(NOT_CONTEXTUAL); // x0=result.value |
5148 context()->DropAndPlug(2, x0); // drop iter and g | 5120 context()->DropAndPlug(2, x0); // drop iter and g |
5149 break; | 5121 break; |
5150 } | 5122 } |
5151 } | 5123 } |
5152 } | 5124 } |
5153 | 5125 |
5154 | 5126 |
5155 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, | 5127 void FullCodeGenerator::EmitGeneratorResume(Expression *generator, |
5156 Expression *value, | 5128 Expression *value, |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5483 } | 5455 } |
5484 } | 5456 } |
5485 | 5457 |
5486 return INTERRUPT; | 5458 return INTERRUPT; |
5487 } | 5459 } |
5488 | 5460 |
5489 | 5461 |
5490 } } // namespace v8::internal | 5462 } } // namespace v8::internal |
5491 | 5463 |
5492 #endif // V8_TARGET_ARCH_ARM64 | 5464 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |