Commit 9fda0c19 authored by erikcorry's avatar erikcorry

MIPS: Do the qNaN fixup at de-serialization time. This is a commit of...

MIPS: Do the qNaN fixup at de-serialization time.  This is a commit of https://chromiumcodereview.appspot.com/10093007/ for Paul Lind

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11405 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent d9f797b4
...@@ -1842,6 +1842,9 @@ bool Isolate::Init(Deserializer* des) { ...@@ -1842,6 +1842,9 @@ bool Isolate::Init(Deserializer* des) {
// stack guard. // stack guard.
heap_.SetStackLimits(); heap_.SetStackLimits();
// Quiet the heap NaN if needed on target platform.
if (des != NULL) Assembler::QuietNaN(heap_.nan_value());
deoptimizer_data_ = new DeoptimizerData; deoptimizer_data_ = new DeoptimizerData;
runtime_profiler_ = new RuntimeProfiler(this); runtime_profiler_ = new RuntimeProfiler(this);
runtime_profiler_->SetUp(); runtime_profiler_->SetUp();
......
...@@ -2137,19 +2137,12 @@ Address Assembler::target_address_at(Address pc) { ...@@ -2137,19 +2137,12 @@ Address Assembler::target_address_at(Address pc) {
} }
#define MIPS_QNAN_HI 0x7ff7ffff // MIPS and ia32 use opposite encoding for qNaN and sNaN, such that ia32
#define MIPS_QNAN_LO 0xffffffff // qNaN is a MIPS sNaN, and ia32 sNaN is MIPS qNaN. If running from a heap
// snapshot generated on ia32, the resulting MIPS sNaN must be quieted.
// OS::nan_value() returns a qNaN.
void Assembler::QuietNaN(HeapObject* object) { void Assembler::QuietNaN(HeapObject* object) {
// Mips has a different encoding of qNaN than ia32, so any heap NaN built HeapNumber::cast(object)->set_value(OS::nan_value());
// with simulator must be re-encoded for the snapshot. Performance hit not
// critical at mksnapshot/build time. We can't use set_value because that
// will put the NaN in an fp register, which changes the bits.
uint64_t mips_qnan_bits =
(static_cast<uint64_t>(MIPS_QNAN_HI) << 32) | MIPS_QNAN_LO;
Address value_ptr = object->address() + HeapNumber::kValueOffset;
memcpy(value_ptr, &mips_qnan_bits, sizeof(mips_qnan_bits));
} }
......
...@@ -8432,6 +8432,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) { ...@@ -8432,6 +8432,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CheckIsBootstrapping) {
} }
RUNTIME_FUNCTION(MaybeObject*, Runtime_GetRootNaN) {
RUNTIME_ASSERT(isolate->bootstrapper()->IsActive());
return isolate->heap()->nan_value();
}
RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) { RUNTIME_FUNCTION(MaybeObject*, Runtime_Call) {
HandleScope scope(isolate); HandleScope scope(isolate);
ASSERT(args.length() >= 2); ASSERT(args.length() >= 2);
......
...@@ -77,6 +77,7 @@ namespace internal { ...@@ -77,6 +77,7 @@ namespace internal {
\ \
/* Utilities */ \ /* Utilities */ \
F(CheckIsBootstrapping, 0, 1) \ F(CheckIsBootstrapping, 0, 1) \
F(GetRootNaN, 0, 1) \
F(Call, -1 /* >= 2 */, 1) \ F(Call, -1 /* >= 2 */, 1) \
F(Apply, 5, 1) \ F(Apply, 5, 1) \
F(GetFunctionDelegate, 1, 1) \ F(GetFunctionDelegate, 1, 1) \
......
...@@ -47,7 +47,7 @@ var $String = global.String; ...@@ -47,7 +47,7 @@ var $String = global.String;
var $Number = global.Number; var $Number = global.Number;
var $Function = global.Function; var $Function = global.Function;
var $Boolean = global.Boolean; var $Boolean = global.Boolean;
var $NaN = 0/0; var $NaN = %GetRootNaN();
var builtins = this; var builtins = this;
// ECMA-262 Section 11.9.3. // ECMA-262 Section 11.9.3.
......
...@@ -1444,8 +1444,6 @@ void Serializer::ObjectSerializer::Serialize() { ...@@ -1444,8 +1444,6 @@ void Serializer::ObjectSerializer::Serialize() {
sink_->PutSection(space, "NewPageSpace"); sink_->PutSection(space, "NewPageSpace");
} }
if (object_->IsNaN()) Assembler::QuietNaN(object_);
// Serialize the map (first word of the object). // Serialize the map (first word of the object).
serializer_->SerializeObject(object_->map(), kPlain, kStartOfObject); serializer_->SerializeObject(object_->map(), kPlain, kStartOfObject);
......
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