Reviewers: mvstanton,
Message:
This should fix the canary crasher.
Port to other platforms is trivial and under way.
Description:
Ensure only whitelisted stubs have sse2 versions in the snapshot.
BUG=
Please review this at https://codereview.chromium.org/26680002/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+69, -26 lines):
M src/assembler.h
M src/assembler.cc
M src/code-stubs.h
M src/code-stubs.cc
M src/ia32/assembler-ia32.h
M src/ia32/assembler-ia32.cc
M src/ia32/code-stubs-ia32.h
M src/ia32/code-stubs-ia32.cc
Index: src/assembler.cc
diff --git a/src/assembler.cc b/src/assembler.cc
index
6581aa1305a459fdc8c90b31d0a9faabf9f78169..9c0542b66483db1bea59ee30f2d7aee579b9d516
100644
--- a/src/assembler.cc
+++ b/src/assembler.cc
@@ -209,20 +209,15 @@ CpuFeatureScope::~CpuFeatureScope() {
//
-----------------------------------------------------------------------------
// Implementation of PlatformFeatureScope
-PlatformFeatureScope::PlatformFeatureScope(CpuFeature f)
- : old_supported_(CpuFeatures::supported_),
- old_found_by_runtime_probing_only_(
- CpuFeatures::found_by_runtime_probing_only_) {
+CrossCompileScope::CrossCompileScope(CpuFeature f)
+ : old_cross_compile_(CpuFeatures::cross_compile_) {
uint64_t mask = static_cast<uint64_t>(1) << f;
- CpuFeatures::supported_ |= mask;
- CpuFeatures::found_by_runtime_probing_only_ &= ~mask;
+ CpuFeatures::cross_compile_ |= mask;
}
-PlatformFeatureScope::~PlatformFeatureScope() {
- CpuFeatures::supported_ = old_supported_;
- CpuFeatures::found_by_runtime_probing_only_ =
- old_found_by_runtime_probing_only_;
+CrossCompileScope::~CrossCompileScope() {
+ CpuFeatures::cross_compile_ = old_cross_compile_;
}
Index: src/assembler.h
diff --git a/src/assembler.h b/src/assembler.h
index
12200740a0becb3ff604b6622be73f73226badfc..4ee22b34dbf25f8a7cd86150260c2d0521394956
100644
--- a/src/assembler.h
+++ b/src/assembler.h
@@ -136,14 +136,13 @@ class CpuFeatureScope BASE_EMBEDDED {
// Enable a unsupported feature within a scope for cross-compiling for a
// different CPU.
-class PlatformFeatureScope BASE_EMBEDDED {
+class CrossCompileScope BASE_EMBEDDED {
public:
- explicit PlatformFeatureScope(CpuFeature f);
- ~PlatformFeatureScope();
+ explicit CrossCompileScope(CpuFeature f);
+ ~CrossCompileScope();
private:
- uint64_t old_supported_;
- uint64_t old_found_by_runtime_probing_only_;
+ uint64_t old_cross_compile_;
};
Index: src/code-stubs.cc
diff --git a/src/code-stubs.cc b/src/code-stubs.cc
index
75b880712c9fc66236a6e897cc6bd50df40fac86..edef17d30f0de01094c23b02c2c1a27ac1b64024
100644
--- a/src/code-stubs.cc
+++ b/src/code-stubs.cc
@@ -129,6 +129,11 @@ Handle<Code> PlatformCodeStub::GenerateCode(Isolate*
isolate) {
}
+void CodeStub::VerifyPlatformFeatures(Isolate* isolate) {
+ ASSERT(!CpuFeatures::cross_compiling());
+}
+
+
Handle<Code> CodeStub::GetCode(Isolate* isolate) {
Factory* factory = isolate->factory();
Heap* heap = isolate->heap();
@@ -141,6 +146,10 @@ Handle<Code> CodeStub::GetCode(Isolate* isolate) {
return Handle<Code>(code);
}
+#ifdef DEBUG
+ VerifyPlatformFeatures(isolate);
+#endif
+
{
HandleScope scope(isolate);
@@ -297,8 +306,6 @@ void BinaryOpStub::GenerateAheadOfTime(Isolate*
isolate) {
// expensive at runtime. When solved we should be able to add most
binops to
// the snapshot instead of hand-picking them.
// Generated list of commonly used stubs
- Generate(Token::ADD, GENERIC, STRING, STRING, NO_OVERWRITE, isolate);
- Generate(Token::ADD, GENERIC, STRING, STRING, OVERWRITE_RIGHT, isolate);
Generate(Token::ADD, INT32, INT32, INT32, NO_OVERWRITE, isolate);
Generate(Token::ADD, INT32, INT32, INT32, OVERWRITE_LEFT, isolate);
Generate(Token::ADD, INT32, INT32, NUMBER, NO_OVERWRITE, isolate);
@@ -326,9 +333,6 @@ void BinaryOpStub::GenerateAheadOfTime(Isolate*
isolate) {
Generate(Token::ADD, SMI, NUMBER, NUMBER, OVERWRITE_RIGHT, isolate);
Generate(Token::ADD, SMI, SMI, INT32, OVERWRITE_LEFT, isolate);
Generate(Token::ADD, SMI, SMI, SMI, OVERWRITE_RIGHT, isolate);
- Generate(Token::ADD, STRING, GENERIC, STRING, NO_OVERWRITE, isolate);
- Generate(Token::ADD, STRING, GENERIC, STRING, OVERWRITE_LEFT, isolate);
- Generate(Token::ADD, STRING, GENERIC, STRING, OVERWRITE_RIGHT, isolate);
Generate(Token::ADD, STRING, STRING, STRING, NO_OVERWRITE, isolate);
Generate(Token::ADD, STRING, STRING, STRING, OVERWRITE_LEFT, isolate);
Generate(Token::ADD, STRING, STRING, STRING, OVERWRITE_RIGHT, isolate);
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index
9b25319a9b82716db689057d95c94d9de2e63ec5..2e70dd4baaaa3be3d620998dfd2a848d8e60cbb2
100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -209,6 +209,7 @@ class CodeStub BASE_EMBEDDED {
// Generates the assembler code for the stub.
virtual Handle<Code> GenerateCode(Isolate* isolate) = 0;
+ virtual void VerifyPlatformFeatures(Isolate* isolate);
// Returns whether the code generated for this stub needs to be
allocated as
// a fixed (non-moveable) code object.
@@ -1043,6 +1044,11 @@ class BinaryOpStub: public HydrogenCodeStub {
return MONOMORPHIC;
}
+ virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE {
+ ASSERT(!CpuFeatures::cross_compiling() ||
+ CpuFeatures::IsCrossCompiling(SSE2));
+ }
+
virtual Code::ExtraICState GetExtraICState() {
bool sse_field = Max(result_state_, Max(left_state_, right_state_)) >
SMI &&
CpuFeatures::IsSafeForSnapshot(SSE2);
@@ -1348,6 +1354,12 @@ class CEntryStub : public PlatformCodeStub {
virtual bool IsPregenerated(Isolate* isolate) V8_OVERRIDE;
static void GenerateAheadOfTime(Isolate* isolate);
+ protected:
+ virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE {
+ ASSERT(!CpuFeatures::cross_compiling() ||
+ (save_doubles_ && CpuFeatures::IsCrossCompiling(SSE2)));
+ };
+
private:
void GenerateCore(MacroAssembler* masm,
Label* throw_normal_exception,
@@ -1766,6 +1778,12 @@ class DoubleToIStub : public PlatformCodeStub {
virtual bool SometimesSetsUpAFrame() { return false; }
+ protected:
+ virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE {
+ ASSERT(!CpuFeatures::cross_compiling() ||
+ CpuFeatures::IsCrossCompiling(SSE2));
+ }
+
private:
static const int kBitsPerRegisterNumber = 6;
STATIC_ASSERT((1L << kBitsPerRegisterNumber) >= Register::kNumRegisters);
Index: src/ia32/assembler-ia32.cc
diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc
index
c2e843197f674b6cccff95f2cd99f3c309c162a7..a4412d0b3fd46eebb10bd6ffc4ed277fe6fa30b4
100644
--- a/src/ia32/assembler-ia32.cc
+++ b/src/ia32/assembler-ia32.cc
@@ -53,6 +53,7 @@ bool CpuFeatures::initialized_ = false;
#endif
uint64_t CpuFeatures::supported_ = 0;
uint64_t CpuFeatures::found_by_runtime_probing_only_ = 0;
+uint64_t CpuFeatures::cross_compile_ = 0;
ExternalReference ExternalReference::cpu_features() {
Index: src/ia32/assembler-ia32.h
diff --git a/src/ia32/assembler-ia32.h b/src/ia32/assembler-ia32.h
index
7c3999b85f112ab9a80c4967c9ecddcb9a4a4b3f..c171421eeda61bc23c230f9e99382413181c7112
100644
--- a/src/ia32/assembler-ia32.h
+++ b/src/ia32/assembler-ia32.h
@@ -535,33 +535,53 @@ class CpuFeatures : public AllStatic {
// Check whether a feature is supported by the target CPU.
static bool IsSupported(CpuFeature f) {
ASSERT(initialized_);
+ if (Check(f, cross_compile_)) return true;
if (f == SSE2 && !FLAG_enable_sse2) return false;
if (f == SSE3 && !FLAG_enable_sse3) return false;
if (f == SSE4_1 && !FLAG_enable_sse4_1) return false;
if (f == CMOV && !FLAG_enable_cmov) return false;
- return (supported_ & (static_cast<uint64_t>(1) << f)) != 0;
+ return Check(f, supported_);
}
static bool IsFoundByRuntimeProbingOnly(CpuFeature f) {
ASSERT(initialized_);
- return (found_by_runtime_probing_only_ &
- (static_cast<uint64_t>(1) << f)) != 0;
+ return Check(f, found_by_runtime_probing_only_);
}
static bool IsSafeForSnapshot(CpuFeature f) {
- return (IsSupported(f) &&
+ return Check(f, cross_compile_) ||
+ (IsSupported(f) &&
(!Serializer::enabled() || !IsFoundByRuntimeProbingOnly(f)));
}
+ static bool cross_compiling() {
+ return cross_compile_ != 0;
+ }
+
+ static bool IsCrossCompiling(CpuFeature f) {
+ uint64_t mask = flag2set(f);
+ return (cross_compile_ & mask) == mask;
+ }
+
private:
+ static bool Check(CpuFeature f, uint64_t set) {
+ return (set & flag2set(f)) != 0;
+ }
+
+ static uint64_t flag2set(CpuFeature f) {
+ return static_cast<uint64_t>(1) << f;
+ }
+
#ifdef DEBUG
static bool initialized_;
#endif
static uint64_t supported_;
static uint64_t found_by_runtime_probing_only_;
+ static uint64_t cross_compile_;
+
friend class ExternalReference;
- friend class PlatformFeatureScope;
+ friend class CrossCompileScope;
DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
};
Index: src/ia32/code-stubs-ia32.cc
diff --git a/src/ia32/code-stubs-ia32.cc b/src/ia32/code-stubs-ia32.cc
index
56798d32c1978329060653e49aac8801489de9be..f69617bcd4782ba2f078e0a3430f3a1faaf0161d
100644
--- a/src/ia32/code-stubs-ia32.cc
+++ b/src/ia32/code-stubs-ia32.cc
@@ -2918,7 +2918,7 @@ void CodeStub::GenerateStubsAheadOfTime(Isolate*
isolate) {
RecordWriteStub::GenerateFixedRegStubsAheadOfTime(isolate);
ArrayConstructorStubBase::GenerateStubsAheadOfTime(isolate);
CreateAllocationSiteStub::GenerateAheadOfTime(isolate);
- PlatformFeatureScope sse2(SSE2);
+ CrossCompileScope sse2(SSE2);
BinaryOpStub::GenerateAheadOfTime(isolate);
}
Index: src/ia32/code-stubs-ia32.h
diff --git a/src/ia32/code-stubs-ia32.h b/src/ia32/code-stubs-ia32.h
index
dc536e7eaee29a40a0fe0e11cebe3eaf0538e89f..e0dc1bcd44b1cd475f8202cf697fcaa90cc13ea5
100644
--- a/src/ia32/code-stubs-ia32.h
+++ b/src/ia32/code-stubs-ia32.h
@@ -148,6 +148,12 @@ class StringAddStub: public PlatformCodeStub {
public:
explicit StringAddStub(StringAddFlags flags) : flags_(flags) {}
+ virtual void VerifyPlatformFeatures(Isolate* isolate) V8_OVERRIDE {
+ ASSERT(!CpuFeatures::cross_compiling() ||
+ (CpuFeatures::IsCrossCompiling(SSE2) &&
+ flags_ == STRING_ADD_CHECK_NONE));
+ }
+
private:
Major MajorKey() { return StringAdd; }
int MinorKey() { return flags_; }
--
--
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/groups/opt_out.