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

Unified Diff: src/ast/ast-value-factory.h

Issue 2152853002: [Interpreter] Avoid accessing on-heap literal in VisitLiteral. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: DCHECK to CHECK Created 4 years, 5 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/conversions.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast-value-factory.h
diff --git a/src/ast/ast-value-factory.h b/src/ast/ast-value-factory.h
index fdca2fed0b615a6c5a573e5e32ef8e4f22a64ae7..9b17ba6514b498c7e0f3a78ced48727466302204 100644
--- a/src/ast/ast-value-factory.h
+++ b/src/ast/ast-value-factory.h
@@ -146,10 +146,8 @@ class AstValue : public ZoneObject {
bool ContainsDot() const { return type_ == NUMBER_WITH_DOT; }
const AstRawString* AsString() const {
- if (type_ == STRING)
- return string_;
- UNREACHABLE();
- return 0;
+ CHECK_EQ(STRING, type_);
+ return string_;
}
double AsNumber() const {
@@ -161,6 +159,11 @@ class AstValue : public ZoneObject {
return 0;
}
+ Smi* AsSmi() const {
+ CHECK_EQ(SMI, type_);
+ return Smi::FromInt(smi_);
+ }
+
bool EqualsString(const AstRawString* string) const {
return type_ == STRING && string_ == string;
}
@@ -169,7 +172,12 @@ class AstValue : public ZoneObject {
bool BooleanValue() const;
+ bool IsSmi() const { return type_ == SMI; }
+ bool IsFalse() const { return type_ == BOOLEAN && !bool_; }
+ bool IsTrue() const { return type_ == BOOLEAN && bool_; }
+ bool IsUndefined() const { return type_ == UNDEFINED; }
bool IsTheHole() const { return type_ == THE_HOLE; }
+ bool IsNull() const { return type_ == NULL_TYPE; }
void Internalize(Isolate* isolate);
@@ -204,10 +212,17 @@ class AstValue : public ZoneObject {
explicit AstValue(double n, bool with_dot) {
if (with_dot) {
type_ = NUMBER_WITH_DOT;
+ number_ = n;
} else {
- type_ = NUMBER;
+ int int_value;
+ if (DoubleToSmiInteger(n, &int_value)) {
+ type_ = SMI;
+ smi_ = int_value;
+ } else {
+ type_ = NUMBER;
+ number_ = n;
+ }
}
- number_ = n;
}
AstValue(Type t, int i) : type_(t) {
« no previous file with comments | « no previous file | src/conversions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698