Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: src/code-stubs.h

Issue 450273002: Extend ToBooleanStub to be able to return oddballs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 1e1d3ccc34bc936c501aa704f3b0aa11a81c7de0..e9b4573b54f7a5f5a145eb7836836879626628e3 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -2315,6 +2315,12 @@ class ToBooleanStub: public HydrogenCodeStub {
NUMBER_OF_TYPES
};
+ enum ResultMode {
+ RESULT_AS_SMI, // For Smi(1) on truthy value, Smi(0) otherwise.
+ RESULT_AS_ODDBALL, // For {true} on truthy value, {false} otherwise.
+ RESULT_AS_INVERSE_ODDBALL // For {false} on truthy value, {true} otherwise.
+ };
+
// At most 8 different types can be distinguished, because the Code object
// only has room for a single byte to hold a set of these types. :-P
STATIC_ASSERT(NUMBER_OF_TYPES <= 8);
@@ -2333,13 +2339,16 @@ class ToBooleanStub: public HydrogenCodeStub {
static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); }
};
- ToBooleanStub(Isolate* isolate, Types types = Types())
- : HydrogenCodeStub(isolate), types_(types) { }
+ ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types())
+ : HydrogenCodeStub(isolate), types_(types), mode_(mode) {}
ToBooleanStub(Isolate* isolate, ExtraICState state)
- : HydrogenCodeStub(isolate), types_(static_cast<byte>(state)) { }
+ : HydrogenCodeStub(isolate),
+ types_(static_cast<byte>(state)),
+ mode_(RESULT_AS_SMI) {}
bool UpdateStatus(Handle<Object> object);
Types GetTypes() { return types_; }
+ ResultMode GetMode() { return mode_; }
virtual Handle<Code> GenerateCode() V8_OVERRIDE;
virtual void InitializeInterfaceDescriptor(
@@ -2351,7 +2360,7 @@ class ToBooleanStub: public HydrogenCodeStub {
virtual bool SometimesSetsUpAFrame() { return false; }
static void InstallDescriptors(Isolate* isolate) {
- ToBooleanStub stub(isolate);
+ ToBooleanStub stub(isolate, RESULT_AS_SMI);
stub.InitializeInterfaceDescriptor(
isolate->code_stub_interface_descriptor(CodeStub::ToBoolean));
}
@@ -2371,13 +2380,19 @@ class ToBooleanStub: public HydrogenCodeStub {
}
private:
+ class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {};
+ class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
+
Major MajorKey() const { return ToBoolean; }
- int NotMissMinorKey() const { return GetExtraICState(); }
+ int NotMissMinorKey() const {
+ return TypesBits::encode(types_.ToByte()) | ResultModeBits::encode(mode_);
+ }
- ToBooleanStub(Isolate* isolate, InitializationState init_state) :
- HydrogenCodeStub(isolate, init_state) {}
+ ToBooleanStub(Isolate* isolate, InitializationState init_state)
+ : HydrogenCodeStub(isolate, init_state), mode_(RESULT_AS_SMI) {}
Types types_;
+ ResultMode mode_;
};
« no previous file with comments | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698