OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 6154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6165 static bool IsLiteralCompareNil(HValue* left, | 6165 static bool IsLiteralCompareNil(HValue* left, |
6166 Token::Value op, | 6166 Token::Value op, |
6167 HValue* right, | 6167 HValue* right, |
6168 Handle<Object> nil, | 6168 Handle<Object> nil, |
6169 HValue** expr) { | 6169 HValue** expr) { |
6170 return MatchLiteralCompareNil(left, op, right, nil, expr) || | 6170 return MatchLiteralCompareNil(left, op, right, nil, expr) || |
6171 MatchLiteralCompareNil(right, op, left, nil, expr); | 6171 MatchLiteralCompareNil(right, op, left, nil, expr); |
6172 } | 6172 } |
6173 | 6173 |
6174 | 6174 |
| 6175 static bool IsLiteralCompareBool(HValue* left, |
| 6176 Token::Value op, |
| 6177 HValue* right) { |
| 6178 return op == Token::EQ_STRICT && |
| 6179 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || |
| 6180 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); |
| 6181 } |
| 6182 |
| 6183 |
6175 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 6184 void HGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
6176 ASSERT(!HasStackOverflow()); | 6185 ASSERT(!HasStackOverflow()); |
6177 ASSERT(current_block() != NULL); | 6186 ASSERT(current_block() != NULL); |
6178 ASSERT(current_block()->HasPredecessor()); | 6187 ASSERT(current_block()->HasPredecessor()); |
6179 if (IsClassOfTest(expr)) { | 6188 if (IsClassOfTest(expr)) { |
6180 CallRuntime* call = expr->left()->AsCallRuntime(); | 6189 CallRuntime* call = expr->left()->AsCallRuntime(); |
6181 ASSERT(call->arguments()->length() == 1); | 6190 ASSERT(call->arguments()->length() == 1); |
6182 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); | 6191 CHECK_ALIVE(VisitForValue(call->arguments()->at(0))); |
6183 HValue* value = Pop(); | 6192 HValue* value = Pop(); |
6184 Literal* literal = expr->right()->AsLiteral(); | 6193 Literal* literal = expr->right()->AsLiteral(); |
(...skipping 27 matching lines...) Expand all Loading... |
6212 return HandleLiteralCompareTypeof(expr, typeof_expr, check); | 6221 return HandleLiteralCompareTypeof(expr, typeof_expr, check); |
6213 } | 6222 } |
6214 HValue* sub_expr = NULL; | 6223 HValue* sub_expr = NULL; |
6215 Factory* f = graph()->isolate()->factory(); | 6224 Factory* f = graph()->isolate()->factory(); |
6216 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { | 6225 if (IsLiteralCompareNil(left, op, right, f->undefined_value(), &sub_expr)) { |
6217 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); | 6226 return HandleLiteralCompareNil(expr, sub_expr, kUndefinedValue); |
6218 } | 6227 } |
6219 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { | 6228 if (IsLiteralCompareNil(left, op, right, f->null_value(), &sub_expr)) { |
6220 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); | 6229 return HandleLiteralCompareNil(expr, sub_expr, kNullValue); |
6221 } | 6230 } |
| 6231 if (IsLiteralCompareBool(left, op, right)) { |
| 6232 HCompareObjectEqAndBranch* result = |
| 6233 new(zone()) HCompareObjectEqAndBranch(left, right); |
| 6234 result->set_position(expr->position()); |
| 6235 return ast_context()->ReturnControl(result, expr->id()); |
| 6236 } |
6222 | 6237 |
6223 if (op == Token::INSTANCEOF) { | 6238 if (op == Token::INSTANCEOF) { |
6224 // Check to see if the rhs of the instanceof is a global function not | 6239 // Check to see if the rhs of the instanceof is a global function not |
6225 // residing in new space. If it is we assume that the function will stay the | 6240 // residing in new space. If it is we assume that the function will stay the |
6226 // same. | 6241 // same. |
6227 Handle<JSFunction> target = Handle<JSFunction>::null(); | 6242 Handle<JSFunction> target = Handle<JSFunction>::null(); |
6228 VariableProxy* proxy = expr->right()->AsVariableProxy(); | 6243 VariableProxy* proxy = expr->right()->AsVariableProxy(); |
6229 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); | 6244 bool global_function = (proxy != NULL) && proxy->var()->IsUnallocated(); |
6230 if (global_function && | 6245 if (global_function && |
6231 info()->has_global_object() && | 6246 info()->has_global_object() && |
(...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7393 } | 7408 } |
7394 } | 7409 } |
7395 | 7410 |
7396 #ifdef DEBUG | 7411 #ifdef DEBUG |
7397 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 7412 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
7398 if (allocator_ != NULL) allocator_->Verify(); | 7413 if (allocator_ != NULL) allocator_->Verify(); |
7399 #endif | 7414 #endif |
7400 } | 7415 } |
7401 | 7416 |
7402 } } // namespace v8::internal | 7417 } } // namespace v8::internal |
OLD | NEW |