There is no undefined Literal.
BUG= R=rossberg@chromium.org Review URL: https://codereview.chromium.org/18429005 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@15724 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
22f2fd8397
commit
d75b34db33
22
src/ast.cc
22
src/ast.cc
@ -71,8 +71,14 @@ bool Expression::IsNullLiteral() {
|
||||
}
|
||||
|
||||
|
||||
bool Expression::IsUndefinedLiteral() {
|
||||
return AsLiteral() != NULL && AsLiteral()->value()->IsUndefined();
|
||||
bool Expression::IsUndefinedLiteral(Isolate* isolate) {
|
||||
VariableProxy* var_proxy = AsVariableProxy();
|
||||
if (var_proxy == NULL) return false;
|
||||
Variable* var = var_proxy->var();
|
||||
// The global identifier "undefined" is immutable. Everything
|
||||
// else could be reassigned.
|
||||
return var != NULL && var->location() == Variable::UNALLOCATED &&
|
||||
var_proxy->name()->Equals(isolate->heap()->undefined_string());
|
||||
}
|
||||
|
||||
|
||||
@ -385,12 +391,13 @@ static bool IsVoidOfLiteral(Expression* expr) {
|
||||
static bool MatchLiteralCompareUndefined(Expression* left,
|
||||
Token::Value op,
|
||||
Expression* right,
|
||||
Expression** expr) {
|
||||
Expression** expr,
|
||||
Isolate* isolate) {
|
||||
if (IsVoidOfLiteral(left) && Token::IsEqualityOp(op)) {
|
||||
*expr = right;
|
||||
return true;
|
||||
}
|
||||
if (left->IsUndefinedLiteral() && Token::IsEqualityOp(op)) {
|
||||
if (left->IsUndefinedLiteral(isolate) && Token::IsEqualityOp(op)) {
|
||||
*expr = right;
|
||||
return true;
|
||||
}
|
||||
@ -398,9 +405,10 @@ static bool MatchLiteralCompareUndefined(Expression* left,
|
||||
}
|
||||
|
||||
|
||||
bool CompareOperation::IsLiteralCompareUndefined(Expression** expr) {
|
||||
return MatchLiteralCompareUndefined(left_, op_, right_, expr) ||
|
||||
MatchLiteralCompareUndefined(right_, op_, left_, expr);
|
||||
bool CompareOperation::IsLiteralCompareUndefined(
|
||||
Expression** expr, Isolate* isolate) {
|
||||
return MatchLiteralCompareUndefined(left_, op_, right_, expr, isolate) ||
|
||||
MatchLiteralCompareUndefined(right_, op_, left_, expr, isolate);
|
||||
}
|
||||
|
||||
|
||||
|
@ -353,8 +353,8 @@ class Expression: public AstNode {
|
||||
// True iff the expression is the null literal.
|
||||
bool IsNullLiteral();
|
||||
|
||||
// True iff the expression is the undefined literal.
|
||||
bool IsUndefinedLiteral();
|
||||
// True if we can prove that the expression is the undefined literal.
|
||||
bool IsUndefinedLiteral(Isolate* isolate);
|
||||
|
||||
// Expression type bounds
|
||||
Bounds bounds() { return bounds_; }
|
||||
@ -1994,7 +1994,7 @@ class CompareOperation: public Expression {
|
||||
|
||||
// Match special cases.
|
||||
bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
|
||||
bool IsLiteralCompareUndefined(Expression** expr);
|
||||
bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate);
|
||||
bool IsLiteralCompareNull(Expression** expr);
|
||||
|
||||
protected:
|
||||
|
@ -1605,7 +1605,7 @@ bool FullCodeGenerator::TryLiteralCompare(CompareOperation* expr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expr->IsLiteralCompareUndefined(&sub_expr)) {
|
||||
if (expr->IsLiteralCompareUndefined(&sub_expr, isolate())) {
|
||||
EmitLiteralCompareNil(expr, sub_expr, kUndefinedValue);
|
||||
return true;
|
||||
}
|
||||
|
@ -8164,7 +8164,7 @@ void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) {
|
||||
if (expr->IsLiteralCompareTypeof(&sub_expr, &check)) {
|
||||
return HandleLiteralCompareTypeof(expr, sub_expr, check);
|
||||
}
|
||||
if (expr->IsLiteralCompareUndefined(&sub_expr)) {
|
||||
if (expr->IsLiteralCompareUndefined(&sub_expr, isolate())) {
|
||||
return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue);
|
||||
}
|
||||
if (expr->IsLiteralCompareNull(&sub_expr)) {
|
||||
|
Loading…
Reference in New Issue
Block a user