(static_cast<uint64_t>(1) << f)) != 0;
}
- class TryForceFeatureScope BASE_EMBEDDED {
- public:
- explicit TryForceFeatureScope(CpuFeature f)
- : old_supported_(CpuFeatures::supported_) {
- if (CanForce()) {
- CpuFeatures::supported_ |= (1u << f);
- }
- }
-
- ~TryForceFeatureScope() {
- if (CanForce()) {
- CpuFeatures::supported_ = old_supported_;
- }
- }
-
- private:
- static bool CanForce() {
- // It's only safe to temporarily force support of CPU features
- // when there's only a single isolate, which is guaranteed when
- // the serializer is enabled.
- return Serializer::enabled();
- }
-
- const unsigned old_supported_;
- };
+ static bool IsSafeForSnapshot(CpuFeature f) {
+ return (IsSupported(f) &&
+ (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f)));
+ }
private:
#ifdef DEBUG
void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
- CpuFeatures::TryForceFeatureScope scope(VFP3);
- if (!CPU::SupportsCrankshaft()) {
- __ Abort("Unreachable code: Cannot optimize without VFP3 support.");
- return;
- }
-
// Lookup the function in the JavaScript frame and push it as an
// argument to the on-stack replacement function.
__ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
#ifdef DEBUG
CpuFeatureScope::CpuFeatureScope(AssemblerBase* assembler, CpuFeature f)
: assembler_(assembler) {
- ASSERT(CpuFeatures::IsSupported(f));
- ASSERT(!Serializer::enabled() ||
- !CpuFeatures::IsFoundByRuntimeProbingOnly(f));
+ ASSERT(CpuFeatures::IsSafeForSnapshot(f));
old_enabled_ = assembler_->enabled_cpu_features();
uint64_t mask = static_cast<uint64_t>(1) << f;
// TODO(svenpanne) This special case below doesn't belong here!
(static_cast<uint64_t>(1) << f)) != 0;
}
- class TryForceFeatureScope BASE_EMBEDDED {
- public:
- explicit TryForceFeatureScope(CpuFeature f)
- : old_supported_(CpuFeatures::supported_) {
- if (CanForce()) {
- CpuFeatures::supported_ |= (static_cast<uint64_t>(1) << f);
- }
- }
-
- ~TryForceFeatureScope() {
- if (CanForce()) {
- CpuFeatures::supported_ = old_supported_;
- }
- }
-
- private:
- static bool CanForce() {
- // It's only safe to temporarily force support of CPU features
- // when there's only a single isolate, which is guaranteed when
- // the serializer is enabled.
- return Serializer::enabled();
- }
-
- const uint64_t old_supported_;
- };
+ static bool IsSafeForSnapshot(CpuFeature f) {
+ return (IsSupported(f) &&
+ (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f)));
+ }
private:
#ifdef DEBUG
void Builtins::Generate_NotifyOSR(MacroAssembler* masm) {
// TODO(kasperl): Do we need to save/restore the XMM registers too?
+ // TODO(mvstanton): We should save these regs, do this in a future
+ // checkin.
// For now, we are relying on the fact that Runtime::NotifyOSR
// doesn't do any garbage collection which allows us to save/restore
void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
- CpuFeatures::TryForceFeatureScope scope(SSE2);
- if (!CpuFeatures::IsSupported(SSE2) && FLAG_debug_code) {
- __ Abort("Unreachable code: Cannot optimize without SSE2 support.");
- return;
- }
-
// Get the loop depth of the stack guard check. This is recorded in
// a test(eax, depth) instruction right after the call.
Label stack_check;
void StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(
Isolate* isolate) {
- StoreBufferOverflowStub stub1(kDontSaveFPRegs);
- stub1.GetCode(isolate)->set_is_pregenerated(true);
-
- CpuFeatures::TryForceFeatureScope scope(SSE2);
- if (CpuFeatures::IsSupported(SSE2)) {
+ StoreBufferOverflowStub stub(kDontSaveFPRegs);
+ stub.GetCode(isolate)->set_is_pregenerated(true);
+ if (CpuFeatures::IsSafeForSnapshot(SSE2)) {
StoreBufferOverflowStub stub2(kSaveFPRegs);
stub2.GetCode(isolate)->set_is_pregenerated(true);
}
class StoreBufferOverflowStub: public PlatformCodeStub {
public:
explicit StoreBufferOverflowStub(SaveFPRegsMode save_fp)
- : save_doubles_(save_fp) { }
+ : save_doubles_(save_fp) {
+ ASSERT(CpuFeatures::IsSafeForSnapshot(SSE2) || save_fp == kDontSaveFPRegs);
+ }
void Generate(MacroAssembler* masm);
regs_(object, // An input reg.
address, // An input reg.
value) { // One scratch reg.
+ ASSERT(CpuFeatures::IsSafeForSnapshot(SSE2) || fp_mode == kDontSaveFPRegs);
}
enum Mode {
namespace internal {
+static SaveFPRegsMode GetSaveFPRegsMode() {
+ // We don't need to save floating point regs when generating the snapshot
+ return CpuFeatures::IsSafeForSnapshot(SSE2) ? kSaveFPRegs : kDontSaveFPRegs;
+}
+
+
// When invoking builtins, we need to record the safepoint in the middle of
// the invoke instruction sequence generated by the macro assembler.
class SafepointGenerator : public CallWrapper {
offset,
value,
temp,
- kSaveFPRegs,
+ GetSaveFPRegsMode(),
EMIT_REMEMBERED_SET,
check_needed);
}
HeapObject::kMapOffset,
temp_map,
temp,
- kSaveFPRegs,
+ GetSaveFPRegsMode(),
OMIT_REMEMBERED_SET,
OMIT_SMI_CHECK);
}
offset,
value,
temp,
- kSaveFPRegs,
+ GetSaveFPRegsMode(),
EMIT_REMEMBERED_SET,
check_needed);
}
offset,
value,
object,
- kSaveFPRegs,
+ GetSaveFPRegsMode(),
EMIT_REMEMBERED_SET,
check_needed);
}
__ RecordWrite(elements,
key,
value,
- kSaveFPRegs,
+ GetSaveFPRegsMode(),
EMIT_REMEMBERED_SET,
check_needed);
}
}
if (!Serializer::enabled()) {
- // Ensure that the stub failure trampoline has been generated.
+ // Ensure that all stubs which need to be generated ahead of time, but
+ // cannot be serialized into the snapshot have been generated.
HandleScope scope(this);
+ StoreBufferOverflowStub::GenerateFixedRegStubsAheadOfTime(this);
CodeStub::GenerateFPStubs(this);
StubFailureTrampolineStub::GenerateAheadOfTime(this);
}
(static_cast<uint64_t>(1) << f)) != 0;
}
- class TryForceFeatureScope BASE_EMBEDDED {
- public:
- explicit TryForceFeatureScope(CpuFeature f)
- : old_supported_(CpuFeatures::supported_) {
- if (CanForce()) {
- CpuFeatures::supported_ |= (1u << f);
- }
- }
-
- ~TryForceFeatureScope() {
- if (CanForce()) {
- CpuFeatures::supported_ = old_supported_;
- }
- }
-
- private:
- static bool CanForce() {
- // It's only safe to temporarily force support of CPU features
- // when there's only a single isolate, which is guaranteed when
- // the serializer is enabled.
- return Serializer::enabled();
- }
-
- const unsigned old_supported_;
- };
-
private:
#ifdef DEBUG
static bool initialized_;
void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
- CpuFeatures::TryForceFeatureScope scope(VFP3);
- if (!CpuFeatures::IsSupported(FPU)) {
- __ Abort("Unreachable code: Cannot optimize without FPU support.");
- return;
- }
-
// Lookup the function in the JavaScript frame and push it as an
// argument to the on-stack replacement function.
__ lw(a0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset));
(static_cast<uint64_t>(1) << f)) != 0;
}
+ static bool IsSafeForSnapshot(CpuFeature f) {
+ return (IsSupported(f) &&
+ (!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f)));
+ }
+
private:
// Safe defaults include SSE2 and CMOV for X64. It is always available, if
// anyone checks, but they shouldn't need to check.