[vm, x64] Remove embedded address from the implementation of math.min/max.
Embedded addresses are not safe for AppAOT and AppJIT snapshots.
Change-Id: Id36adb2e430bfc92c409ec96db15f2ad2151b2cb
Reviewed-on: https://dart-review.googlesource.com/58060
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/runtime/vm/compiler/backend/il_x64.cc b/runtime/vm/compiler/backend/il_x64.cc
index 57490ec..aeb619b 100644
--- a/runtime/vm/compiler/backend/il_x64.cc
+++ b/runtime/vm/compiler/backend/il_x64.cc
@@ -4412,8 +4412,7 @@
__ jmp(&done, Assembler::kNearJump);
__ Bind(&returns_nan);
- static double kNaN = NAN;
- __ LoadImmediate(temp, Immediate(reinterpret_cast<intptr_t>(&kNaN)));
+ __ movq(temp, Address(THR, Thread::double_nan_address_offset()));
__ movsd(result, Address(temp, 0));
__ jmp(&done, Assembler::kNearJump);
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index 68b4a05..5f31782 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -152,6 +152,8 @@
}
}
+static const double double_nan_constant = NAN;
+
static const struct ALIGN16 {
uint64_t a;
uint64_t b;
diff --git a/runtime/vm/thread.h b/runtime/vm/thread.h
index 4f176a1..c90586b 100644
--- a/runtime/vm/thread.h
+++ b/runtime/vm/thread.h
@@ -148,6 +148,8 @@
NativeEntry::AutoScopeNativeCallWrapperEntry(), 0) \
V(RawString**, predefined_symbols_address_, Symbols::PredefinedAddress(), \
NULL) \
+ V(uword, double_nan_address_, reinterpret_cast<uword>(&double_nan_constant), \
+ 0) \
V(uword, double_negate_address_, \
reinterpret_cast<uword>(&double_negate_constant), 0) \
V(uword, double_abs_address_, reinterpret_cast<uword>(&double_abs_constant), \