| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 } | 427 } |
| 428 } | 428 } |
| 429 | 429 |
| 430 | 430 |
| 431 void LCodeGen::DoCallFunction(LCallFunction* instr) { | 431 void LCodeGen::DoCallFunction(LCallFunction* instr) { |
| 432 ASSERT(ToRegister(instr->function()).Is(x1)); | 432 ASSERT(ToRegister(instr->function()).Is(x1)); |
| 433 ASSERT(ToRegister(instr->result()).Is(x0)); | 433 ASSERT(ToRegister(instr->result()).Is(x0)); |
| 434 | 434 |
| 435 int arity = instr->arity(); | 435 int arity = instr->arity(); |
| 436 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); | 436 CallFunctionStub stub(arity, NO_CALL_FUNCTION_FLAGS); |
| 437 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); | 437 if (instr->hydrogen()->IsTailCall()) { |
| 438 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 438 if (NeedsEagerFrame()) { |
| 439 __ Mov(masm()->StackPointer(), fp); |
| 440 } |
| 441 __ Jump(stub.GetCode(isolate()), RelocInfo::CODE_TARGET); |
| 442 } else { |
| 443 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr); |
| 444 __ Ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 445 } |
| 439 } | 446 } |
| 440 | 447 |
| 441 | 448 |
| 442 void LCodeGen::DoCallNew(LCallNew* instr) { | 449 void LCodeGen::DoCallNew(LCallNew* instr) { |
| 443 ASSERT(instr->IsMarkedAsCall()); | 450 ASSERT(instr->IsMarkedAsCall()); |
| 444 ASSERT(ToRegister(instr->constructor()).is(x1)); | 451 ASSERT(ToRegister(instr->constructor()).is(x1)); |
| 445 | 452 |
| 446 __ Mov(x0, instr->arity()); | 453 __ Mov(x0, instr->arity()); |
| 447 // No cell in x2 for construct type feedback in optimized code. | 454 // No cell in x2 for construct type feedback in optimized code. |
| 448 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); | 455 Handle<Object> undefined_value(isolate()->factory()->undefined_value()); |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 // Other constants not implemented. | 1130 // Other constants not implemented. |
| 1124 Abort(kToOperand32UnsupportedImmediate); | 1131 Abort(kToOperand32UnsupportedImmediate); |
| 1125 } | 1132 } |
| 1126 } | 1133 } |
| 1127 // Other cases are not implemented. | 1134 // Other cases are not implemented. |
| 1128 UNREACHABLE(); | 1135 UNREACHABLE(); |
| 1129 return Operand(0); | 1136 return Operand(0); |
| 1130 } | 1137 } |
| 1131 | 1138 |
| 1132 | 1139 |
| 1140 static ptrdiff_t ArgumentsOffsetWithoutFrame(ptrdiff_t index) { |
| 1141 ASSERT(index < 0); |
| 1142 return -(index + 1) * kPointerSize; |
| 1143 } |
| 1144 |
| 1145 |
| 1133 MemOperand LCodeGen::ToMemOperand(LOperand* op) const { | 1146 MemOperand LCodeGen::ToMemOperand(LOperand* op) const { |
| 1134 ASSERT(op != NULL); | 1147 ASSERT(op != NULL); |
| 1135 ASSERT(!op->IsRegister()); | 1148 ASSERT(!op->IsRegister()); |
| 1136 ASSERT(!op->IsDoubleRegister()); | 1149 ASSERT(!op->IsDoubleRegister()); |
| 1137 ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); | 1150 ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot()); |
| 1138 return MemOperand(fp, StackSlotOffset(op->index())); | 1151 if (NeedsEagerFrame()) { |
| 1152 return MemOperand(fp, StackSlotOffset(op->index())); |
| 1153 } else { |
| 1154 // Retrieve parameter without eager stack-frame relative to the |
| 1155 // stack-pointer. |
| 1156 return MemOperand(masm()->StackPointer(), |
| 1157 ArgumentsOffsetWithoutFrame(op->index())); |
| 1158 } |
| 1139 } | 1159 } |
| 1140 | 1160 |
| 1141 | 1161 |
| 1142 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { | 1162 Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const { |
| 1143 HConstant* constant = chunk_->LookupConstant(op); | 1163 HConstant* constant = chunk_->LookupConstant(op); |
| 1144 ASSERT(chunk_->LookupLiteralRepresentation(op).IsSmiOrTagged()); | 1164 ASSERT(chunk_->LookupLiteralRepresentation(op).IsSmiOrTagged()); |
| 1145 return constant->handle(isolate()); | 1165 return constant->handle(isolate()); |
| 1146 } | 1166 } |
| 1147 | 1167 |
| 1148 | 1168 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 __ Str(temp2, MemOperand(result, temp1)); | 1423 __ Str(temp2, MemOperand(result, temp1)); |
| 1404 __ Subs(temp1, temp1, kPointerSize); | 1424 __ Subs(temp1, temp1, kPointerSize); |
| 1405 __ B(ge, &loop); | 1425 __ B(ge, &loop); |
| 1406 | 1426 |
| 1407 __ Add(result, result, kHeapObjectTag); | 1427 __ Add(result, result, kHeapObjectTag); |
| 1408 } | 1428 } |
| 1409 } | 1429 } |
| 1410 | 1430 |
| 1411 | 1431 |
| 1412 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { | 1432 void LCodeGen::DoDeferredAllocate(LAllocate* instr) { |
| 1413 Register result = ToRegister(instr->result()); | |
| 1414 | |
| 1415 // TODO(3095996): Get rid of this. For now, we need to make the | 1433 // TODO(3095996): Get rid of this. For now, we need to make the |
| 1416 // result register contain a valid pointer because it is already | 1434 // result register contain a valid pointer because it is already |
| 1417 // contained in the register pointer map. | 1435 // contained in the register pointer map. |
| 1418 __ Mov(result, Operand(Smi::FromInt(0))); | 1436 __ Mov(ToRegister(instr->result()), Operand(Smi::FromInt(0))); |
| 1419 | 1437 |
| 1420 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); | 1438 PushSafepointRegistersScope scope(this, Safepoint::kWithRegisters); |
| 1439 // We're in a SafepointRegistersScope so we can use any scratch registers. |
| 1440 Register size = x0; |
| 1421 if (instr->size()->IsConstantOperand()) { | 1441 if (instr->size()->IsConstantOperand()) { |
| 1422 int32_t size = ToInteger32(LConstantOperand::cast(instr->size())); | 1442 __ Mov(size, Operand(ToSmi(LConstantOperand::cast(instr->size())))); |
| 1423 // Use result as a scratch register. | |
| 1424 __ Mov(result, Operand(Smi::FromInt(size))); | |
| 1425 __ Push(result); | |
| 1426 } else { | 1443 } else { |
| 1427 Register size = ToRegister(instr->size()); | 1444 __ SmiTag(size, ToRegister(instr->size())); |
| 1428 __ SmiTag(size); | |
| 1429 __ Push(size); | |
| 1430 } | 1445 } |
| 1446 int flags = AllocateDoubleAlignFlag::encode( |
| 1447 instr->hydrogen()->MustAllocateDoubleAligned()); |
| 1431 if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { | 1448 if (instr->hydrogen()->IsOldPointerSpaceAllocation()) { |
| 1432 ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); | 1449 ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation()); |
| 1433 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); | 1450 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 1434 CallRuntimeFromDeferred(Runtime::kAllocateInOldPointerSpace, 1, instr); | 1451 flags = AllocateTargetSpace::update(flags, OLD_POINTER_SPACE); |
| 1435 } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { | 1452 } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) { |
| 1436 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); | 1453 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation()); |
| 1437 CallRuntimeFromDeferred(Runtime::kAllocateInOldDataSpace, 1, instr); | 1454 flags = AllocateTargetSpace::update(flags, OLD_DATA_SPACE); |
| 1438 } else { | 1455 } else { |
| 1439 CallRuntimeFromDeferred(Runtime::kAllocateInNewSpace, 1, instr); | 1456 flags = AllocateTargetSpace::update(flags, NEW_SPACE); |
| 1440 } | 1457 } |
| 1441 __ StoreToSafepointRegisterSlot(x0, result); | 1458 __ Mov(x10, Operand(Smi::FromInt(flags))); |
| 1459 __ Push(size, x10); |
| 1460 |
| 1461 CallRuntimeFromDeferred(Runtime::kAllocateInTargetSpace, 2, instr); |
| 1462 __ StoreToSafepointRegisterSlot(x0, ToRegister(instr->result())); |
| 1442 } | 1463 } |
| 1443 | 1464 |
| 1444 | 1465 |
| 1445 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { | 1466 void LCodeGen::DoApplyArguments(LApplyArguments* instr) { |
| 1446 Register receiver = ToRegister(instr->receiver()); | 1467 Register receiver = ToRegister(instr->receiver()); |
| 1447 Register function = ToRegister(instr->function()); | 1468 Register function = ToRegister(instr->function()); |
| 1448 Register length = ToRegister(instr->length()); | 1469 Register length = ToRegister(instr->length()); |
| 1449 Register elements = ToRegister(instr->elements()); | 1470 Register elements = ToRegister(instr->elements()); |
| 1450 Register scratch = x5; | 1471 Register scratch = x5; |
| 1451 ASSERT(receiver.Is(x0)); // Used for parameter count. | 1472 ASSERT(receiver.Is(x0)); // Used for parameter count. |
| (...skipping 4163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5615 __ Bind(&out_of_object); | 5636 __ Bind(&out_of_object); |
| 5616 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 5637 __ Ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
| 5617 // Index is equal to negated out of object property index plus 1. | 5638 // Index is equal to negated out of object property index plus 1. |
| 5618 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); | 5639 __ Sub(result, result, Operand::UntagSmiAndScale(index, kPointerSizeLog2)); |
| 5619 __ Ldr(result, FieldMemOperand(result, | 5640 __ Ldr(result, FieldMemOperand(result, |
| 5620 FixedArray::kHeaderSize - kPointerSize)); | 5641 FixedArray::kHeaderSize - kPointerSize)); |
| 5621 __ Bind(&done); | 5642 __ Bind(&done); |
| 5622 } | 5643 } |
| 5623 | 5644 |
| 5624 } } // namespace v8::internal | 5645 } } // namespace v8::internal |
| OLD | NEW |