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