Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/src/crankshaft/arm/lithium-arm.cc b/src/crankshaft/arm/lithium-arm.cc
index 4072982..d8ee9cd 100644
--- a/src/crankshaft/arm/lithium-arm.cc
+++ b/src/crankshaft/arm/lithium-arm.cc
@@ -877,7 +877,7 @@
LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) {
LInstruction* result = new (zone()) LPrologue();
- if (info_->num_heap_slots() > 0) {
+ if (info_->scope()->num_heap_slots() > 0) {
result = MarkAsCall(result, instr);
}
return result;
@@ -934,17 +934,6 @@
}
-LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
- LOperand* left =
- UseFixed(instr->left(), InstanceOfDescriptor::LeftRegister());
- LOperand* right =
- UseFixed(instr->right(), InstanceOfDescriptor::RightRegister());
- LOperand* context = UseFixed(instr->context(), cp);
- LInstanceOf* result = new (zone()) LInstanceOf(context, left, right);
- return MarkAsCall(DefineFixed(result, r0), instr);
-}
-
-
LInstruction* LChunkBuilder::DoHasInPrototypeChainAndBranch(
HHasInPrototypeChainAndBranch* instr) {
LOperand* object = UseRegister(instr->object());
@@ -2351,13 +2340,18 @@
LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
- info()->MarkAsDeferredCalling();
- LOperand* context = UseAny(instr->context());
LOperand* size = UseRegisterOrConstant(instr->size());
LOperand* temp1 = TempRegister();
LOperand* temp2 = TempRegister();
- LAllocate* result = new(zone()) LAllocate(context, size, temp1, temp2);
- return AssignPointerMap(DefineAsRegister(result));
+ if (instr->IsAllocationFolded()) {
+ LFastAllocate* result = new (zone()) LFastAllocate(size, temp1, temp2);
+ return DefineAsRegister(result);
+ } else {
+ info()->MarkAsDeferredCalling();
+ LOperand* context = UseAny(instr->context());
+ LAllocate* result = new (zone()) LAllocate(context, size, temp1, temp2);
+ return AssignPointerMap(DefineAsRegister(result));
+ }
}
diff --git a/src/crankshaft/arm/lithium-arm.h b/src/crankshaft/arm/lithium-arm.h
index 60fe79d..2ec992f 100644
--- a/src/crankshaft/arm/lithium-arm.h
+++ b/src/crankshaft/arm/lithium-arm.h
@@ -67,6 +67,7 @@
V(Drop) \
V(Dummy) \
V(DummyUse) \
+ V(FastAllocate) \
V(FlooringDivByConstI) \
V(FlooringDivByPowerOf2I) \
V(FlooringDivI) \
@@ -78,7 +79,6 @@
V(HasInPrototypeChainAndBranch) \
V(HasInstanceTypeAndBranch) \
V(InnerAllocatedObject) \
- V(InstanceOf) \
V(InstructionGap) \
V(Integer32ToDouble) \
V(InvokeFunction) \
@@ -151,7 +151,6 @@
V(UnknownOSRValue) \
V(WrapReceiver)
-
#define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
Opcode opcode() const final { return LInstruction::k##type; } \
void CompileToNative(LCodeGen* generator) final; \
@@ -1135,22 +1134,6 @@
};
-class LInstanceOf final : public LTemplateInstruction<1, 3, 0> {
- public:
- LInstanceOf(LOperand* context, LOperand* left, LOperand* right) {
- inputs_[0] = context;
- inputs_[1] = left;
- inputs_[2] = right;
- }
-
- LOperand* context() const { return inputs_[0]; }
- LOperand* left() const { return inputs_[1]; }
- LOperand* right() const { return inputs_[2]; }
-
- DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of")
-};
-
-
class LHasInPrototypeChainAndBranch final : public LControlInstruction<2, 0> {
public:
LHasInPrototypeChainAndBranch(LOperand* object, LOperand* prototype) {
@@ -2391,6 +2374,21 @@
DECLARE_HYDROGEN_ACCESSOR(Allocate)
};
+class LFastAllocate final : public LTemplateInstruction<1, 1, 2> {
+ public:
+ LFastAllocate(LOperand* size, LOperand* temp1, LOperand* temp2) {
+ inputs_[0] = size;
+ temps_[0] = temp1;
+ temps_[1] = temp2;
+ }
+
+ LOperand* size() { return inputs_[0]; }
+ LOperand* temp1() { return temps_[0]; }
+ LOperand* temp2() { return temps_[1]; }
+
+ DECLARE_CONCRETE_INSTRUCTION(FastAllocate, "fast-allocate")
+ DECLARE_HYDROGEN_ACCESSOR(Allocate)
+};
class LTypeof final : public LTemplateInstruction<1, 2, 0> {
public:
diff --git a/src/crankshaft/arm/lithium-codegen-arm.cc b/src/crankshaft/arm/lithium-codegen-arm.cc
index c64aac3..340642a 100644
--- a/src/crankshaft/arm/lithium-codegen-arm.cc
+++ b/src/crankshaft/arm/lithium-codegen-arm.cc
@@ -329,8 +329,6 @@
} else {
__ bl(&call_deopt_entry);
}
- info()->LogDeoptCallPosition(masm()->pc_offset(),
- table_entry->deopt_info.inlining_id);
masm()->CheckConstPool(false, false);
}
@@ -823,7 +821,7 @@
__ stop("trap_on_deopt", condition);
}
- Deoptimizer::DeoptInfo deopt_info = MakeDeoptInfo(instr, deopt_reason);
+ Deoptimizer::DeoptInfo deopt_info = MakeDeoptInfo(instr, deopt_reason, id);
DCHECK(info()->IsStub() || frame_is_built_);
// Go through jump table if we need to handle condition, build frame, or
@@ -832,7 +830,6 @@
!info()->saves_caller_doubles()) {
DeoptComment(deopt_info);
__ Call(entry, RelocInfo::RUNTIME_ENTRY);
- info()->LogDeoptCallPosition(masm()->pc_offset(), deopt_info.inlining_id);
} else {
Deoptimizer::JumpTableEntry table_entry(entry, deopt_info, bailout_type,
!frame_is_built_);
@@ -2498,16 +2495,6 @@
}
-void LCodeGen::DoInstanceOf(LInstanceOf* instr) {
- DCHECK(ToRegister(instr->context()).is(cp));
- DCHECK(ToRegister(instr->left()).is(InstanceOfDescriptor::LeftRegister()));
- DCHECK(ToRegister(instr->right()).is(InstanceOfDescriptor::RightRegister()));
- DCHECK(ToRegister(instr->result()).is(r0));
- InstanceOfStub stub(isolate());
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
-}
-
-
void LCodeGen::DoHasInPrototypeChainAndBranch(
LHasInPrototypeChainAndBranch* instr) {
Register const object = ToRegister(instr->object());
@@ -4031,11 +4018,6 @@
if (instr->NeedsCanonicalization()) {
// Force a canonical NaN.
- if (masm()->emit_debug_code()) {
- __ vmrs(ip);
- __ tst(ip, Operand(kVFPDefaultNaNModeControlBit));
- __ Assert(ne, kDefaultNaNModeNotSet);
- }
__ VFPCanonicalizeNaN(double_scratch, value);
__ vstr(double_scratch, scratch, 0);
} else {
@@ -4193,7 +4175,15 @@
LOperand* key = instr->key();
if (key->IsConstantOperand()) {
- __ Move(r3, Operand(ToSmi(LConstantOperand::cast(key))));
+ LConstantOperand* constant_key = LConstantOperand::cast(key);
+ int32_t int_key = ToInteger32(constant_key);
+ if (Smi::IsValid(int_key)) {
+ __ mov(r3, Operand(Smi::FromInt(int_key)));
+ } else {
+ // We should never get here at runtime because there is a smi check on
+ // the key before this point.
+ __ stop("expected smi");
+ }
} else {
__ Move(r3, ToRegister(key));
__ SmiTag(r3);
@@ -4494,7 +4484,7 @@
if (FLAG_inline_new) {
__ LoadRoot(tmp3, Heap::kHeapNumberMapRootIndex);
- __ AllocateHeapNumber(dst, tmp1, tmp2, tmp3, &slow, DONT_TAG_RESULT);
+ __ AllocateHeapNumber(dst, tmp1, tmp2, tmp3, &slow);
__ b(&done);
}
@@ -4518,15 +4508,13 @@
__ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
RecordSafepointWithRegisters(
instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
- __ sub(r0, r0, Operand(kHeapObjectTag));
__ StoreToSafepointRegisterSlot(r0, dst);
}
// Done. Put the value in dbl_scratch into the value of the allocated heap
// number.
__ bind(&done);
- __ vstr(dbl_scratch, dst, HeapNumber::kValueOffset);
- __ add(dst, dst, Operand(kHeapObjectTag));
+ __ vstr(dbl_scratch, FieldMemOperand(dst, HeapNumber::kValueOffset));
}
@@ -4551,16 +4539,12 @@
DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr);
if (FLAG_inline_new) {
__ LoadRoot(scratch, Heap::kHeapNumberMapRootIndex);
- // We want the untagged address first for performance
- __ AllocateHeapNumber(reg, temp1, temp2, scratch, deferred->entry(),
- DONT_TAG_RESULT);
+ __ AllocateHeapNumber(reg, temp1, temp2, scratch, deferred->entry());
} else {
__ jmp(deferred->entry());
}
__ bind(deferred->exit());
- __ vstr(input_reg, reg, HeapNumber::kValueOffset);
- // Now that we have finished with the object's real address tag it
- __ add(reg, reg, Operand(kHeapObjectTag));
+ __ vstr(input_reg, FieldMemOperand(reg, HeapNumber::kValueOffset));
}
@@ -4581,7 +4565,6 @@
__ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
RecordSafepointWithRegisters(
instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
- __ sub(r0, r0, Operand(kHeapObjectTag));
__ StoreToSafepointRegisterSlot(r0, reg);
}
@@ -5105,7 +5088,7 @@
Register scratch2 = ToRegister(instr->temp2());
// Allocate memory for the object.
- AllocationFlags flags = TAG_OBJECT;
+ AllocationFlags flags = NO_ALLOCATION_FLAGS;
if (instr->hydrogen()->MustAllocateDoubleAligned()) {
flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT);
}
@@ -5114,6 +5097,11 @@
flags = static_cast<AllocationFlags>(flags | PRETENURE);
}
+ if (instr->hydrogen()->IsAllocationFoldingDominator()) {
+ flags = static_cast<AllocationFlags>(flags | ALLOCATION_FOLDING_DOMINATOR);
+ }
+ DCHECK(!instr->hydrogen()->IsAllocationFolded());
+
if (instr->size()->IsConstantOperand()) {
int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
CHECK(size <= Page::kMaxRegularHeapObjectSize);
@@ -5181,6 +5169,49 @@
CallRuntimeFromDeferred(
Runtime::kAllocateInTargetSpace, 2, instr, instr->context());
__ StoreToSafepointRegisterSlot(r0, result);
+
+ if (instr->hydrogen()->IsAllocationFoldingDominator()) {
+ AllocationFlags allocation_flags = NO_ALLOCATION_FLAGS;
+ if (instr->hydrogen()->IsOldSpaceAllocation()) {
+ DCHECK(!instr->hydrogen()->IsNewSpaceAllocation());
+ allocation_flags = static_cast<AllocationFlags>(flags | PRETENURE);
+ }
+ // If the allocation folding dominator allocate triggered a GC, allocation
+ // happend in the runtime. We have to reset the top pointer to virtually
+ // undo the allocation.
+ ExternalReference allocation_top =
+ AllocationUtils::GetAllocationTopReference(isolate(), allocation_flags);
+ Register top_address = scratch0();
+ __ sub(r0, r0, Operand(kHeapObjectTag));
+ __ mov(top_address, Operand(allocation_top));
+ __ str(r0, MemOperand(top_address));
+ __ add(r0, r0, Operand(kHeapObjectTag));
+ }
+}
+
+void LCodeGen::DoFastAllocate(LFastAllocate* instr) {
+ DCHECK(instr->hydrogen()->IsAllocationFolded());
+ DCHECK(!instr->hydrogen()->IsAllocationFoldingDominator());
+ Register result = ToRegister(instr->result());
+ Register scratch1 = ToRegister(instr->temp1());
+ Register scratch2 = ToRegister(instr->temp2());
+
+ AllocationFlags flags = ALLOCATION_FOLDED;
+ if (instr->hydrogen()->MustAllocateDoubleAligned()) {
+ flags = static_cast<AllocationFlags>(flags | DOUBLE_ALIGNMENT);
+ }
+ if (instr->hydrogen()->IsOldSpaceAllocation()) {
+ DCHECK(!instr->hydrogen()->IsNewSpaceAllocation());
+ flags = static_cast<AllocationFlags>(flags | PRETENURE);
+ }
+ if (instr->size()->IsConstantOperand()) {
+ int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
+ CHECK(size <= Page::kMaxRegularHeapObjectSize);
+ __ FastAllocate(size, result, scratch1, scratch2, flags);
+ } else {
+ Register size = ToRegister(instr->size());
+ __ FastAllocate(size, result, scratch1, scratch2, flags);
+ }
}
diff --git a/src/crankshaft/arm/lithium-codegen-arm.h b/src/crankshaft/arm/lithium-codegen-arm.h
index 8bbacc3..30a26f2 100644
--- a/src/crankshaft/arm/lithium-codegen-arm.h
+++ b/src/crankshaft/arm/lithium-codegen-arm.h
@@ -135,8 +135,6 @@
#undef DECLARE_DO
private:
- LanguageMode language_mode() const { return info()->language_mode(); }
-
Scope* scope() const { return scope_; }
Register scratch0() { return r9; }