Index: src/x64/lithium-codegen-x64.cc |
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc |
index d48aecbf25381c9817b94466f14cd59b566a9fe8..85e7ac0bf08d4bb4cca0678b7e6fd528cf2304f4 100644 |
--- a/src/x64/lithium-codegen-x64.cc |
+++ b/src/x64/lithium-codegen-x64.cc |
@@ -4322,6 +4322,23 @@ void LCodeGen::EmitDeepCopy(Handle<JSObject> object, |
void LCodeGen::DoFastLiteral(LFastLiteral* instr) { |
int size = instr->hydrogen()->total_size(); |
+ ElementsKind boilerplate_elements_kind = |
+ instr->hydrogen()->boilerplate()->GetElementsKind(); |
+ |
+ // Deopt if the literal boilerplate ElementsKind is of a type different than |
+ // the expected one. The check isn't necessary if the boilerplate has already |
+ // been converted to FAST_ELEMENTS. |
+ if (boilerplate_elements_kind != FAST_ELEMENTS) { |
+ __ LoadHeapObject(rbx, instr->hydrogen()->boilerplate()); |
+ __ movq(rcx, FieldOperand(rbx, HeapObject::kMapOffset)); |
+ // Load the map's "bit field 2". |
+ __ movb(rcx, FieldOperand(rcx, Map::kBitField2Offset)); |
+ // Retrieve elements_kind from bit field 2. |
+ __ and_(rcx, Immediate(Map::kElementsKindMask)); |
+ __ cmpb(rcx, Immediate(boilerplate_elements_kind << |
+ Map::kElementsKindShift)); |
+ DeoptimizeIf(not_equal, instr->environment()); |
+ } |
// Allocate all objects that are part of the literal in one big |
// allocation. This avoids multiple limit checks. |