OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 6893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6904 const ZoneList<HValue*>* arguments_values = args->arguments_values(); | 6904 const ZoneList<HValue*>* arguments_values = args->arguments_values(); |
6905 int arguments_count = arguments_values->length(); | 6905 int arguments_count = arguments_values->length(); |
6906 Push(BuildWrapReceiver(receiver, function)); | 6906 Push(BuildWrapReceiver(receiver, function)); |
6907 for (int i = 1; i < arguments_count; i++) { | 6907 for (int i = 1; i < arguments_count; i++) { |
6908 Push(arguments_values->at(i)); | 6908 Push(arguments_values->at(i)); |
6909 } | 6909 } |
6910 | 6910 |
6911 Handle<JSFunction> known_function; | 6911 Handle<JSFunction> known_function; |
6912 if (function->IsConstant()) { | 6912 if (function->IsConstant()) { |
6913 HConstant* constant_function = HConstant::cast(function); | 6913 HConstant* constant_function = HConstant::cast(function); |
6914 known_function = Handle<JSFunction>::cast(constant_function->handle()); | 6914 known_function = Handle<JSFunction>::cast( |
| 6915 constant_function->handle(isolate())); |
6915 int args_count = arguments_count - 1; // Excluding receiver. | 6916 int args_count = arguments_count - 1; // Excluding receiver. |
6916 if (TryInlineApply(known_function, expr, args_count)) return true; | 6917 if (TryInlineApply(known_function, expr, args_count)) return true; |
6917 } | 6918 } |
6918 | 6919 |
6919 Drop(arguments_count - 1); | 6920 Drop(arguments_count - 1); |
6920 PushAndAdd(New<HPushArgument>(Pop())); | 6921 PushAndAdd(New<HPushArgument>(Pop())); |
6921 for (int i = 1; i < arguments_count; i++) { | 6922 for (int i = 1; i < arguments_count; i++) { |
6922 PushAndAdd(New<HPushArgument>(arguments_values->at(i))); | 6923 PushAndAdd(New<HPushArgument>(arguments_values->at(i))); |
6923 } | 6924 } |
6924 | 6925 |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7984 Expression* sub_expr, | 7985 Expression* sub_expr, |
7985 Handle<String> check) { | 7986 Handle<String> check) { |
7986 CHECK_ALIVE(VisitForTypeOf(sub_expr)); | 7987 CHECK_ALIVE(VisitForTypeOf(sub_expr)); |
7987 HValue* value = Pop(); | 7988 HValue* value = Pop(); |
7988 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); | 7989 HTypeofIsAndBranch* instr = new(zone()) HTypeofIsAndBranch(value, check); |
7989 instr->set_position(expr->position()); | 7990 instr->set_position(expr->position()); |
7990 return ast_context()->ReturnControl(instr, expr->id()); | 7991 return ast_context()->ReturnControl(instr, expr->id()); |
7991 } | 7992 } |
7992 | 7993 |
7993 | 7994 |
7994 static bool IsLiteralCompareBool(HValue* left, | 7995 static bool IsLiteralCompareBool(Isolate* isolate, |
| 7996 HValue* left, |
7995 Token::Value op, | 7997 Token::Value op, |
7996 HValue* right) { | 7998 HValue* right) { |
7997 return op == Token::EQ_STRICT && | 7999 return op == Token::EQ_STRICT && |
7998 ((left->IsConstant() && HConstant::cast(left)->handle()->IsBoolean()) || | 8000 ((left->IsConstant() && |
7999 (right->IsConstant() && HConstant::cast(right)->handle()->IsBoolean())); | 8001 HConstant::cast(left)->handle(isolate)->IsBoolean()) || |
| 8002 (right->IsConstant() && |
| 8003 HConstant::cast(right)->handle(isolate)->IsBoolean())); |
8000 } | 8004 } |
8001 | 8005 |
8002 | 8006 |
8003 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { | 8007 void HOptimizedGraphBuilder::VisitCompareOperation(CompareOperation* expr) { |
8004 ASSERT(!HasStackOverflow()); | 8008 ASSERT(!HasStackOverflow()); |
8005 ASSERT(current_block() != NULL); | 8009 ASSERT(current_block() != NULL); |
8006 ASSERT(current_block()->HasPredecessor()); | 8010 ASSERT(current_block()->HasPredecessor()); |
8007 | 8011 |
8008 // Check for a few fast cases. The AST visiting behavior must be in sync | 8012 // Check for a few fast cases. The AST visiting behavior must be in sync |
8009 // with the full codegen: We don't push both left and right values onto | 8013 // with the full codegen: We don't push both left and right values onto |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8041 Representation right_rep = Representation::FromType(right_type); | 8045 Representation right_rep = Representation::FromType(right_type); |
8042 | 8046 |
8043 CHECK_ALIVE(VisitForValue(expr->left())); | 8047 CHECK_ALIVE(VisitForValue(expr->left())); |
8044 CHECK_ALIVE(VisitForValue(expr->right())); | 8048 CHECK_ALIVE(VisitForValue(expr->right())); |
8045 | 8049 |
8046 HValue* context = environment()->context(); | 8050 HValue* context = environment()->context(); |
8047 HValue* right = Pop(); | 8051 HValue* right = Pop(); |
8048 HValue* left = Pop(); | 8052 HValue* left = Pop(); |
8049 Token::Value op = expr->op(); | 8053 Token::Value op = expr->op(); |
8050 | 8054 |
8051 if (IsLiteralCompareBool(left, op, right)) { | 8055 if (IsLiteralCompareBool(isolate(), left, op, right)) { |
8052 HCompareObjectEqAndBranch* result = | 8056 HCompareObjectEqAndBranch* result = |
8053 New<HCompareObjectEqAndBranch>(left, right); | 8057 New<HCompareObjectEqAndBranch>(left, right); |
8054 result->set_position(expr->position()); | 8058 result->set_position(expr->position()); |
8055 return ast_context()->ReturnControl(result, expr->id()); | 8059 return ast_context()->ReturnControl(result, expr->id()); |
8056 } | 8060 } |
8057 | 8061 |
8058 if (op == Token::INSTANCEOF) { | 8062 if (op == Token::INSTANCEOF) { |
8059 // Check to see if the rhs of the instanceof is a global function not | 8063 // Check to see if the rhs of the instanceof is a global function not |
8060 // residing in new space. If it is we assume that the function will stay the | 8064 // residing in new space. If it is we assume that the function will stay the |
8061 // same. | 8065 // same. |
(...skipping 1664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9726 if (ShouldProduceTraceOutput()) { | 9730 if (ShouldProduceTraceOutput()) { |
9727 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 9731 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
9728 } | 9732 } |
9729 | 9733 |
9730 #ifdef DEBUG | 9734 #ifdef DEBUG |
9731 graph_->Verify(false); // No full verify. | 9735 graph_->Verify(false); // No full verify. |
9732 #endif | 9736 #endif |
9733 } | 9737 } |
9734 | 9738 |
9735 } } // namespace v8::internal | 9739 } } // namespace v8::internal |
OLD | NEW |