Commit 383a1672 authored by olivf@chromium.org's avatar olivf@chromium.org

Add X87 implementations for Integer32ToDouble, DoubleToI, DoubleToSmi

Additionally refactor the X87Stack tracking

BUG=
R=verwaest@chromium.org

Review URL: https://codereview.chromium.org/20781007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16246 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 1bff3fd5
......@@ -1641,6 +1641,13 @@ void Assembler::fstp_s(const Operand& adr) {
}
void Assembler::fst_s(const Operand& adr) {
EnsureSpace ensure_space(this);
EMIT(0xD9);
emit_operand(edx, adr);
}
void Assembler::fstp_d(const Operand& adr) {
EnsureSpace ensure_space(this);
EMIT(0xDD);
......
......@@ -929,6 +929,7 @@ class Assembler : public AssemblerBase {
void fld_d(const Operand& adr);
void fstp_s(const Operand& adr);
void fst_s(const Operand& adr);
void fstp_d(const Operand& adr);
void fst_d(const Operand& adr);
......
This diff is collapsed.
......@@ -68,7 +68,7 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
osr_pc_offset_(-1),
last_lazy_deopt_pc_(0),
frame_is_built_(false),
x87_stack_depth_(0),
x87_stack_(assembler),
safepoints_(info->zone()),
resolver_(this),
expected_safepoint_kind_(Safepoint::kSimple),
......@@ -122,14 +122,23 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
void X87Mov(X87Register reg, Operand src,
X87OperandType operand = kX87DoubleOperand);
void X87Mov(Operand src, X87Register reg);
void X87Mov(Operand src, X87Register reg,
X87OperandType operand = kX87DoubleOperand);
void X87PrepareBinaryOp(
X87Register left, X87Register right, X87Register result);
void X87LoadForUsage(X87Register reg);
void X87PrepareToWrite(X87Register reg);
void X87CommitWrite(X87Register reg);
void X87PrepareToWrite(X87Register reg) { x87_stack_.PrepareToWrite(reg); }
void X87CommitWrite(X87Register reg) { x87_stack_.CommitWrite(reg); }
void X87Fxch(X87Register reg, int other_slot = 0) {
x87_stack_.Fxch(reg, other_slot);
}
bool X87StackEmpty() {
return x87_stack_.depth() == 0;
}
Handle<Object> ToHandle(LConstantOperand* op) const;
......@@ -399,15 +408,13 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
// register, or a stack slot operand.
void EmitPushTaggedOperand(LOperand* operand);
void X87Fxch(X87Register reg, int other_slot = 0);
void X87Fld(Operand src, X87OperandType opts);
void X87Free(X87Register reg);
void FlushX87StackIfNecessary(LInstruction* instr);
void EmitFlushX87ForDeopt();
bool X87StackContains(X87Register reg);
int X87ArrayIndex(X87Register reg);
int x87_st2idx(int pos);
void FlushX87StackIfNecessary(LInstruction* instr) {
x87_stack_.FlushIfNecessary(instr, this);
}
friend class LGapResolver;
#ifdef _MSC_VER
// On windows, you may not access the stack more than one page below
......@@ -438,8 +445,48 @@ class LCodeGen V8_FINAL BASE_EMBEDDED {
int osr_pc_offset_;
int last_lazy_deopt_pc_;
bool frame_is_built_;
X87Register x87_stack_[X87Register::kNumAllocatableRegisters];
int x87_stack_depth_;
class X87Stack {
public:
explicit X87Stack(MacroAssembler* masm) : stack_depth_(0), masm_(masm) { }
explicit X87Stack(const X87Stack& other)
: stack_depth_(0), masm_(other.masm_) {
stack_depth_ = other.stack_depth_;
for (int i = 0; i < stack_depth_; i++) {
stack_[i] = other.stack_[i];
}
}
bool operator==(const X87Stack& other) const {
if (stack_depth_ != other.stack_depth_) return false;
for (int i = 0; i < stack_depth_; i++) {
if (!stack_[i].is(other.stack_[i])) return false;
}
return true;
}
bool Contains(X87Register reg);
void Fxch(X87Register reg, int other_slot = 0);
void Free(X87Register reg);
void PrepareToWrite(X87Register reg);
void CommitWrite(X87Register reg);
void FlushIfNecessary(LInstruction* instr, LCodeGen* cgen);
int depth() const { return stack_depth_; }
void pop() { stack_depth_--; }
void push(X87Register reg) {
ASSERT(stack_depth_ < X87Register::kNumAllocatableRegisters);
stack_[stack_depth_] = reg;
stack_depth_++;
}
MacroAssembler* masm() const { return masm_; }
private:
int ArrayIndex(X87Register reg);
int st2idx(int pos);
X87Register stack_[X87Register::kNumAllocatableRegisters];
int stack_depth_;
MacroAssembler* const masm_;
};
X87Stack x87_stack_;
// Builder that keeps track of safepoints in the code. The table
// itself is emitted at the end of the generated code.
......
......@@ -277,10 +277,9 @@ class LInstruction : public ZoneObject {
bool ClobbersRegisters() const { return IsCall(); }
virtual bool ClobbersDoubleRegisters() const {
return IsCall() ||
(!CpuFeatures::IsSupported(SSE2) &&
// We only have rudimentary X87Stack tracking, thus in general
// cannot handle deoptimization nor phi-nodes.
(HasEnvironment() || IsControl()));
// cannot handle phi-nodes.
(!CpuFeatures::IsSafeForSnapshot(SSE2) && IsControl());
}
virtual bool HasResult() const = 0;
......@@ -1542,11 +1541,6 @@ class LLoadNamedField V8_FINAL : public LTemplateInstruction<1, 1, 0> {
inputs_[0] = object;
}
virtual bool ClobbersDoubleRegisters() const {
return !CpuFeatures::IsSupported(SSE2) &&
!hydrogen()->representation().IsDouble();
}
LOperand* object() { return inputs_[0]; }
DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field")
......@@ -2206,8 +2200,6 @@ class LNumberUntagD V8_FINAL : public LTemplateInstruction<1, 1, 1> {
LOperand* value() { return inputs_[0]; }
LOperand* temp() { return temps_[0]; }
virtual bool ClobbersDoubleRegisters() const V8_OVERRIDE { return false; }
DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag")
DECLARE_HYDROGEN_ACCESSOR(Change);
};
......
// Copyright 2013 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --noenable-sse2
// Regression for register allocation.
var x;
var a = new Float32Array([1,2, 4, 6, 8, 11, NaN, 1/0, -3])
var val = 2.1*a[1]*a[0]*a[1*2*3*0]*a[1*1]*1.0;
assertEquals(8.4, val);
// Regression for double-phis
var a;
var t = true;
var res = [2.5, 2];
for (var i = 0; i < 2; i++) {
if (t) {
a = 1.5;
} else {
a = true;
}
assertEquals(res[i], a+1);
t = false;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment