Revision: 21861
Author: [email protected]
Date: Mon Jun 16 20:45:15 2014 UTC
Log: Version 3.26.31.5 (revert r21509, r21858, r21525)
Avoid HeapObject check in HStoreNamedField.
Add unit test for regression in GVN caused by field type
MIPS: Avoid HeapObject check in HStoreNamedField.
BUG=v8:3347
LOG=N
[email protected],[email protected]
Review URL: https://codereview.chromium.org/334743011
http://code.google.com/p/v8/source/detail?r=21861
Deleted:
/branches/3.26/test/mjsunit/regress/regress-gvn-ftt.js
Modified:
/branches/3.26/src/arm/lithium-arm.cc
/branches/3.26/src/arm/lithium-codegen-arm.cc
/branches/3.26/src/arm/macro-assembler-arm.cc
/branches/3.26/src/arm64/lithium-arm64.cc
/branches/3.26/src/arm64/lithium-codegen-arm64.cc
/branches/3.26/src/arm64/macro-assembler-arm64.cc
/branches/3.26/src/hydrogen-instructions.cc
/branches/3.26/src/hydrogen-instructions.h
/branches/3.26/src/hydrogen.cc
/branches/3.26/src/ia32/lithium-codegen-ia32.cc
/branches/3.26/src/ia32/lithium-ia32.cc
/branches/3.26/src/ia32/macro-assembler-ia32.cc
/branches/3.26/src/mips/lithium-codegen-mips.cc
/branches/3.26/src/mips/lithium-mips.cc
/branches/3.26/src/mips/macro-assembler-mips.cc
/branches/3.26/src/version.cc
/branches/3.26/src/x64/lithium-codegen-x64.cc
/branches/3.26/src/x64/lithium-x64.cc
/branches/3.26/src/x64/macro-assembler-x64.cc
=======================================
--- /branches/3.26/test/mjsunit/regress/regress-gvn-ftt.js Mon Jun 16
13:43:37 2014 UTC
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Flags: --allow-natives-syntax --track-field-types --use-gvn
-
-function A(id) {
- this.id = id;
-}
-
-var a1 = new A(1);
-var a2 = new A(2);
-
-
-var g;
-function f(o, value) {
- g = o.o;
- o.o = value;
- return o.o;
-}
-
-var obj = {o: a1};
-
-f(obj, a1);
-f(obj, a1);
-%OptimizeFunctionOnNextCall(f);
-assertEquals(a2.id, f(obj, a2).id);
=======================================
--- /branches/3.26/src/arm/lithium-arm.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/arm/lithium-arm.cc Mon Jun 16 20:45:15 2014 UTC
@@ -2297,7 +2297,13 @@
// We need a temporary register for write barrier of the map field.
LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL;
- return new(zone()) LStoreNamedField(obj, val, temp);
+ LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp);
+ if (!instr->access().IsExternalMemory() &&
+ instr->field_representation().IsHeapObject() &&
+ !instr->value()->type().IsHeapObject()) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/3.26/src/arm/lithium-codegen-arm.cc Mon Jun 16 13:43:37 2014
UTC
+++ /branches/3.26/src/arm/lithium-codegen-arm.cc Mon Jun 16 20:45:15 2014
UTC
@@ -4069,12 +4069,23 @@
return;
}
- __ AssertNotSmi(object);
+ SmiCheck check_needed =
+ instr->hydrogen()->value()->IsHeapObject()
+ ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
- ASSERT(!representation.IsSmi() ||
- !instr->value()->IsConstantOperand() ||
- IsSmi(LConstantOperand::cast(instr->value())));
- if (representation.IsDouble()) {
+ ASSERT(!(representation.IsSmi() &&
+ instr->value()->IsConstantOperand() &&
+ !IsSmi(LConstantOperand::cast(instr->value()))));
+ if (representation.IsHeapObject()) {
+ Register value = ToRegister(instr->value());
+ if (!instr->hydrogen()->value()->type().IsHeapObject()) {
+ __ SmiTst(value);
+ DeoptimizeIf(eq, instr->environment());
+
+ // We know now that value is not a smi, so we can omit the check
below.
+ check_needed = OMIT_SMI_CHECK;
+ }
+ } else if (representation.IsDouble()) {
ASSERT(access.IsInobject());
ASSERT(!instr->hydrogen()->has_transition());
ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
@@ -4116,7 +4127,7 @@
GetLinkRegisterState(),
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
} else {
__ ldr(scratch, FieldMemOperand(object, JSObject::kPropertiesOffset));
@@ -4132,7 +4143,7 @@
GetLinkRegisterState(),
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
}
}
=======================================
--- /branches/3.26/src/arm/macro-assembler-arm.cc Mon Jun 16 13:43:37 2014
UTC
+++ /branches/3.26/src/arm/macro-assembler-arm.cc Mon Jun 16 20:45:15 2014
UTC
@@ -405,11 +405,6 @@
} else if (r.IsInteger16() || r.IsUInteger16()) {
strh(src, dst);
} else {
- if (r.IsHeapObject()) {
- AssertNotSmi(src);
- } else if (r.IsSmi()) {
- AssertSmi(src);
- }
str(src, dst);
}
}
=======================================
--- /branches/3.26/src/arm64/lithium-arm64.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/arm64/lithium-arm64.cc Mon Jun 16 20:45:15 2014 UTC
@@ -2246,7 +2246,13 @@
temp0 = TempRegister();
}
- return new(zone()) LStoreNamedField(object, value, temp0, temp1);
+ LStoreNamedField* result =
+ new(zone()) LStoreNamedField(object, value, temp0, temp1);
+ if (instr->field_representation().IsHeapObject() &&
+ !instr->value()->type().IsHeapObject()) {
+ return AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/3.26/src/arm64/lithium-codegen-arm64.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/arm64/lithium-codegen-arm64.cc Mon Jun 16 20:45:15
2014 UTC
@@ -5257,11 +5257,7 @@
Register value = ToRegister(instr->value());
__ Store(value, MemOperand(object, offset), representation);
return;
- }
-
- __ AssertNotSmi(object);
-
- if (representation.IsDouble()) {
+ } else if (representation.IsDouble()) {
ASSERT(access.IsInobject());
ASSERT(!instr->hydrogen()->has_transition());
ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
@@ -5272,9 +5268,19 @@
Register value = ToRegister(instr->value());
- ASSERT(!representation.IsSmi() ||
- !instr->value()->IsConstantOperand() ||
- IsInteger32Constant(LConstantOperand::cast(instr->value())));
+ SmiCheck check_needed = instr->hydrogen()->value()->IsHeapObject()
+ ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
+
+ ASSERT(!(representation.IsSmi() &&
+ instr->value()->IsConstantOperand() &&
+ !IsInteger32Constant(LConstantOperand::cast(instr->value()))));
+ if (representation.IsHeapObject() &&
+ !instr->hydrogen()->value()->type().IsHeapObject()) {
+ DeoptimizeIfSmi(value, instr->environment());
+
+ // We know now that value is not a smi, so we can omit the check below.
+ check_needed = OMIT_SMI_CHECK;
+ }
if (instr->hydrogen()->has_transition()) {
Handle<Map> transition = instr->hydrogen()->transition_map();
@@ -5334,7 +5340,7 @@
GetLinkRegisterState(),
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
}
=======================================
--- /branches/3.26/src/arm64/macro-assembler-arm64.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/arm64/macro-assembler-arm64.cc Mon Jun 16 20:45:15
2014 UTC
@@ -557,11 +557,6 @@
Str(rt.W(), addr);
} else {
ASSERT(rt.Is64Bits());
- if (r.IsHeapObject()) {
- AssertNotSmi(rt);
- } else if (r.IsSmi()) {
- AssertSmi(rt);
- }
Str(rt, addr);
}
}
=======================================
--- /branches/3.26/src/hydrogen-instructions.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/hydrogen-instructions.cc Mon Jun 16 20:45:15 2014 UTC
@@ -873,7 +873,6 @@
case HValue::kSeqStringGetChar:
case HValue::kStoreCodeEntry:
case HValue::kStoreKeyed:
- case HValue::kStoreNamedField:
case HValue::kStoreNamedGeneric:
case HValue::kStringCharCodeAt:
case HValue::kStringCharFromCode:
@@ -922,6 +921,7 @@
case HValue::kStoreContextSlot:
case HValue::kStoreGlobalCell:
case HValue::kStoreKeyedGeneric:
+ case HValue::kStoreNamedField:
case HValue::kStringAdd:
case HValue::kStringCompareAndBranch:
case HValue::kSub:
=======================================
--- /branches/3.26/src/hydrogen-instructions.h Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/hydrogen-instructions.h Mon Jun 16 20:45:15 2014 UTC
@@ -6662,12 +6662,6 @@
return ReceiverObjectNeedsWriteBarrier(object(), transition(),
new_space_dominator());
}
-
- SmiCheck SmiCheckForWriteBarrier() const {
- if (field_representation().IsHeapObject()) return OMIT_SMI_CHECK;
- if (value()->IsHeapObject()) return OMIT_SMI_CHECK;
- return INLINE_SMI_CHECK;
- }
Representation field_representation() const {
return access_.representation();
=======================================
--- /branches/3.26/src/hydrogen.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/hydrogen.cc Mon Jun 16 20:45:15 2014 UTC
@@ -5391,13 +5391,16 @@
value, STORE_TO_INITIALIZED_ENTRY);
}
} else {
- if (field_access.representation().IsHeapObject()) {
- BuildCheckHeapObject(value);
- }
-
if (!info->field_maps()->is_empty()) {
ASSERT(field_access.representation().IsHeapObject());
+ BuildCheckHeapObject(value);
value = Add<HCheckMaps>(value, info->field_maps());
+
+ // TODO(bmeurer): This is a dirty hack to avoid repeating the smi
check
+ // that was already performed by the HCheckHeapObject above in the
+ // HStoreNamedField below. We should really do this right instead and
+ // make Crankshaft aware of Representation::HeapObject().
+ field_access =
field_access.WithRepresentation(Representation::Tagged());
}
// This is a normal store.
=======================================
--- /branches/3.26/src/ia32/lithium-codegen-ia32.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/ia32/lithium-codegen-ia32.cc Mon Jun 16 20:45:15
2014 UTC
@@ -4359,12 +4359,30 @@
}
Register object = ToRegister(instr->object());
- __ AssertNotSmi(object);
+ SmiCheck check_needed =
+ instr->hydrogen()->value()->IsHeapObject()
+ ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
- ASSERT(!representation.IsSmi() ||
- !instr->value()->IsConstantOperand() ||
- IsSmi(LConstantOperand::cast(instr->value())));
- if (representation.IsDouble()) {
+ ASSERT(!(representation.IsSmi() &&
+ instr->value()->IsConstantOperand() &&
+ !IsSmi(LConstantOperand::cast(instr->value()))));
+ if (representation.IsHeapObject()) {
+ if (instr->value()->IsConstantOperand()) {
+ LConstantOperand* operand_value =
LConstantOperand::cast(instr->value());
+ if (chunk_->LookupConstant(operand_value)->HasSmiValue()) {
+ DeoptimizeIf(no_condition, instr->environment());
+ }
+ } else {
+ if (!instr->hydrogen()->value()->type().IsHeapObject()) {
+ Register value = ToRegister(instr->value());
+ __ test(value, Immediate(kSmiTagMask));
+ DeoptimizeIf(zero, instr->environment());
+
+ // We know now that value is not a smi, so we can omit the check
below.
+ check_needed = OMIT_SMI_CHECK;
+ }
+ }
+ } else if (representation.IsDouble()) {
ASSERT(access.IsInobject());
ASSERT(!instr->hydrogen()->has_transition());
ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
@@ -4437,7 +4455,7 @@
temp,
GetSaveFPRegsMode(isolate()),
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
}
=======================================
--- /branches/3.26/src/ia32/lithium-ia32.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/ia32/lithium-ia32.cc Mon Jun 16 20:45:15 2014 UTC
@@ -2419,7 +2419,16 @@
// We need a temporary register for write barrier of the map field.
LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL;
- return new(zone()) LStoreNamedField(obj, val, temp, temp_map);
+ LInstruction* result =
+ new(zone()) LStoreNamedField(obj, val, temp, temp_map);
+ if (!instr->access().IsExternalMemory() &&
+ instr->field_representation().IsHeapObject() &&
+ (val->IsConstantOperand()
+ ? HConstant::cast(instr->value())->HasSmiValue()
+ : !instr->value()->type().IsHeapObject())) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/3.26/src/ia32/macro-assembler-ia32.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/ia32/macro-assembler-ia32.cc Mon Jun 16 20:45:15
2014 UTC
@@ -55,11 +55,6 @@
} else if (r.IsInteger16() || r.IsUInteger16()) {
mov_w(dst, src);
} else {
- if (r.IsHeapObject()) {
- AssertNotSmi(src);
- } else if (r.IsSmi()) {
- AssertSmi(src);
- }
mov(dst, src);
}
}
=======================================
--- /branches/3.26/src/mips/lithium-codegen-mips.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/mips/lithium-codegen-mips.cc Mon Jun 16 20:45:15
2014 UTC
@@ -4066,12 +4066,23 @@
return;
}
- __ AssertNotSmi(object);
+ SmiCheck check_needed =
+ instr->hydrogen()->value()->IsHeapObject()
+ ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
- ASSERT(!representation.IsSmi() ||
- !instr->value()->IsConstantOperand() ||
- IsSmi(LConstantOperand::cast(instr->value())));
- if (representation.IsDouble()) {
+ ASSERT(!(representation.IsSmi() &&
+ instr->value()->IsConstantOperand() &&
+ !IsSmi(LConstantOperand::cast(instr->value()))));
+ if (representation.IsHeapObject()) {
+ Register value = ToRegister(instr->value());
+ if (!instr->hydrogen()->value()->type().IsHeapObject()) {
+ __ SmiTst(value, scratch);
+ DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg));
+
+ // We know now that value is not a smi, so we can omit the check
below.
+ check_needed = OMIT_SMI_CHECK;
+ }
+ } else if (representation.IsDouble()) {
ASSERT(access.IsInobject());
ASSERT(!instr->hydrogen()->has_transition());
ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
@@ -4113,7 +4124,7 @@
GetRAState(),
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
} else {
__ lw(scratch, FieldMemOperand(object, JSObject::kPropertiesOffset));
@@ -4129,7 +4140,7 @@
GetRAState(),
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- instr->hydrogen()->SmiCheckForWriteBarrier());
+ check_needed);
}
}
}
=======================================
--- /branches/3.26/src/mips/lithium-mips.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/mips/lithium-mips.cc Mon Jun 16 20:45:15 2014 UTC
@@ -2248,7 +2248,13 @@
// We need a temporary register for write barrier of the map field.
LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL;
- return new(zone()) LStoreNamedField(obj, val, temp);
+ LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp);
+ if (!instr->access().IsExternalMemory() &&
+ instr->field_representation().IsHeapObject() &&
+ !instr->value()->type().IsHeapObject()) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/3.26/src/mips/macro-assembler-mips.cc Mon Jun 16 13:43:37
2014 UTC
+++ /branches/3.26/src/mips/macro-assembler-mips.cc Mon Jun 16 20:45:15
2014 UTC
@@ -56,11 +56,6 @@
} else if (r.IsInteger16() || r.IsUInteger16()) {
sh(src, dst);
} else {
- if (r.IsHeapObject()) {
- AssertNotSmi(src);
- } else if (r.IsSmi()) {
- AssertSmi(src);
- }
sw(src, dst);
}
}
=======================================
--- /branches/3.26/src/version.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/version.cc Mon Jun 16 20:45:15 2014 UTC
@@ -35,7 +35,7 @@
#define MAJOR_VERSION 3
#define MINOR_VERSION 26
#define BUILD_NUMBER 31
-#define PATCH_LEVEL 4
+#define PATCH_LEVEL 5
// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define IS_CANDIDATE_VERSION 0
=======================================
--- /branches/3.26/src/x64/lithium-codegen-x64.cc Mon Jun 16 13:43:37 2014
UTC
+++ /branches/3.26/src/x64/lithium-codegen-x64.cc Mon Jun 16 20:45:15 2014
UTC
@@ -3990,12 +3990,29 @@
}
Register object = ToRegister(instr->object());
- __ AssertNotSmi(object);
+ SmiCheck check_needed = hinstr->value()->IsHeapObject()
+ ? OMIT_SMI_CHECK : INLINE_SMI_CHECK;
+
+ ASSERT(!(representation.IsSmi() &&
+ instr->value()->IsConstantOperand() &&
+ !IsInteger32Constant(LConstantOperand::cast(instr->value()))));
+ if (representation.IsHeapObject()) {
+ if (instr->value()->IsConstantOperand()) {
+ LConstantOperand* operand_value =
LConstantOperand::cast(instr->value());
+ if (chunk_->LookupConstant(operand_value)->HasSmiValue()) {
+ DeoptimizeIf(no_condition, instr->environment());
+ }
+ } else {
+ if (!hinstr->value()->type().IsHeapObject()) {
+ Register value = ToRegister(instr->value());
+ Condition cc = masm()->CheckSmi(value);
+ DeoptimizeIf(cc, instr->environment());
- ASSERT(!representation.IsSmi() ||
- !instr->value()->IsConstantOperand() ||
- IsInteger32Constant(LConstantOperand::cast(instr->value())));
- if (representation.IsDouble()) {
+ // We know now that value is not a smi, so we can omit the check
below.
+ check_needed = OMIT_SMI_CHECK;
+ }
+ }
+ } else if (representation.IsDouble()) {
ASSERT(access.IsInobject());
ASSERT(!hinstr->has_transition());
ASSERT(!hinstr->NeedsWriteBarrier());
@@ -4080,7 +4097,7 @@
temp,
kSaveFPRegs,
EMIT_REMEMBERED_SET,
- hinstr->SmiCheckForWriteBarrier());
+ check_needed);
}
}
=======================================
--- /branches/3.26/src/x64/lithium-x64.cc Mon Jun 16 13:43:37 2014 UTC
+++ /branches/3.26/src/x64/lithium-x64.cc Mon Jun 16 20:45:15 2014 UTC
@@ -2311,7 +2311,15 @@
LOperand* temp = (!is_in_object || needs_write_barrier ||
needs_write_barrier_for_map) ? TempRegister() : NULL;
- return new(zone()) LStoreNamedField(obj, val, temp);
+ LInstruction* result = new(zone()) LStoreNamedField(obj, val, temp);
+ if (!instr->access().IsExternalMemory() &&
+ instr->field_representation().IsHeapObject() &&
+ (val->IsConstantOperand()
+ ? HConstant::cast(instr->value())->HasSmiValue()
+ : !instr->value()->type().IsHeapObject())) {
+ result = AssignEnvironment(result);
+ }
+ return result;
}
=======================================
--- /branches/3.26/src/x64/macro-assembler-x64.cc Mon Jun 16 13:43:37 2014
UTC
+++ /branches/3.26/src/x64/macro-assembler-x64.cc Mon Jun 16 20:45:15 2014
UTC
@@ -921,11 +921,6 @@
} else if (r.IsInteger32()) {
movl(dst, src);
} else {
- if (r.IsHeapObject()) {
- AssertNotSmi(src);
- } else if (r.IsSmi()) {
- AssertSmi(src);
- }
movp(dst, src);
}
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.