Reviewers: Jakob,
Description:
Smi immediates are not supported on x64. Do not use it.
[email protected]
BUG=358059
LOG=N
Please review this at https://codereview.chromium.org/217083003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+19, -17 lines):
M src/x64/lithium-codegen-x64.cc
M src/x64/lithium-x64.cc
A + test/mjsunit/regress/regress-358059.js
Index: src/x64/lithium-codegen-x64.cc
diff --git a/src/x64/lithium-codegen-x64.cc b/src/x64/lithium-codegen-x64.cc
index
0c907e44ad5889b47b212751a683e5c1c8792202..477ff363c5122757250e92edd794dce39de11eb8
100644
--- a/src/x64/lithium-codegen-x64.cc
+++ b/src/x64/lithium-codegen-x64.cc
@@ -1820,6 +1820,7 @@ void LCodeGen::DoAddI(LAddI* instr) {
if (LAddI::UseLea(instr->hydrogen()) && !left->Equals(instr->result())) {
if (right->IsConstantOperand()) {
+ ASSERT(!target_rep.IsSmi()); // Not support for smi-immediates.
int32_t offset = ToInteger32(LConstantOperand::cast(right));
if (is_p) {
__ leap(ToRegister(instr->result()),
@@ -1838,6 +1839,7 @@ void LCodeGen::DoAddI(LAddI* instr) {
}
} else {
if (right->IsConstantOperand()) {
+ ASSERT(!target_rep.IsSmi()); // Not support for smi-immediates.
if (is_p) {
__ addp(ToRegister(left),
Immediate(ToInteger32(LConstantOperand::cast(right))));
Index: src/x64/lithium-x64.cc
diff --git a/src/x64/lithium-x64.cc b/src/x64/lithium-x64.cc
index
b174a0e24a62c0eb98eb887673f821a30ef9496f..d1c77311ecf9da440af7748ffbf7567f6e5c78c2
100644
--- a/src/x64/lithium-x64.cc
+++ b/src/x64/lithium-x64.cc
@@ -1532,14 +1532,19 @@ LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
ASSERT(instr->right()->representation().Equals(instr->representation()));
LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
HValue* right_candidate = instr->BetterRightOperand();
- LOperand* right = use_lea
- ? UseRegisterOrConstantAtStart(right_candidate)
- : UseOrConstantAtStart(right_candidate);
+ LOperand* right;
+ if (instr->representation().IsSmi()) {
+ // We cannot add a tagged immediate to a tagged value,
+ // so we request it in a register.
+ right = UseRegisterAtStart(right_candidate);
+ } else {
+ right = use_lea ? UseRegisterOrConstantAtStart(right_candidate)
+ : UseOrConstantAtStart(right_candidate);
+ }
LAddI* add = new(zone()) LAddI(left, right);
bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
- LInstruction* result = use_lea
- ? DefineAsRegister(add)
- : DefineSameAsFirst(add);
+ LInstruction* result = use_lea ? DefineAsRegister(add)
+ : DefineSameAsFirst(add);
if (can_overflow) {
result = AssignEnvironment(result);
}
Index: test/mjsunit/regress/regress-358059.js
diff --git a/test/mjsunit/regress/regress-is-smi-repr.js
b/test/mjsunit/regress/regress-358059.js
similarity index 56%
copy from test/mjsunit/regress/regress-is-smi-repr.js
copy to test/mjsunit/regress/regress-358059.js
index
e9f2b516b57c630e4eddf8dac4da546a19ee08de..30738f9ae890b9a1e02e4ed9039d15b6101ecc08
100644
--- a/test/mjsunit/regress/regress-is-smi-repr.js
+++ b/test/mjsunit/regress/regress-358059.js
@@ -4,15 +4,10 @@
// Flags: --allow-natives-syntax
-"use strict";
-
-var global;
-
-function g() { global = this; }
-Object.defineProperty(Number.prototype, "prop", { get: g });
-function f(s) { s.prop; }
-
-f(1);
-f(1);
+function f(a, b) { return b + (a.x++); }
+var o = {};
+o.__defineGetter__('x', function() { return 1; });
+assertEquals(4, f(o, 3));
+assertEquals(4, f(o, 3));
%OptimizeFunctionOnNextCall(f);
-f(1);
+assertEquals(4, f(o, 3));
--
--
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.