| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 14 matching lines...) Expand all Loading... |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "ast.h" | 30 #include "ast.h" |
| 31 #include "jump-target-inl.h" | 31 #include "jump-target-inl.h" |
| 32 #include "parser.h" | 32 #include "parser.h" |
| 33 #include "scopes.h" | 33 #include "scopes.h" |
| 34 #include "string-stream.h" | 34 #include "string-stream.h" |
| 35 #include "stub-cache.h" |
| 35 | 36 |
| 36 namespace v8 { | 37 namespace v8 { |
| 37 namespace internal { | 38 namespace internal { |
| 38 | 39 |
| 39 AstSentinels::AstSentinels() | 40 AstSentinels::AstSentinels() |
| 40 : this_proxy_(true), | 41 : this_proxy_(true), |
| 41 identifier_proxy_(false), | 42 identifier_proxy_(false), |
| 42 valid_left_hand_side_sentinel_(), | 43 valid_left_hand_side_sentinel_(), |
| 43 this_property_(&this_proxy_, NULL, 0), | 44 this_property_(&this_proxy_, NULL, 0), |
| 44 call_sentinel_(NULL, NULL, 0) { | 45 call_sentinel_(NULL, NULL, 0) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 | 119 |
| 119 | 120 |
| 120 Assignment::Assignment(Token::Value op, | 121 Assignment::Assignment(Token::Value op, |
| 121 Expression* target, | 122 Expression* target, |
| 122 Expression* value, | 123 Expression* value, |
| 123 int pos) | 124 int pos) |
| 124 : op_(op), | 125 : op_(op), |
| 125 target_(target), | 126 target_(target), |
| 126 value_(value), | 127 value_(value), |
| 127 pos_(pos), | 128 pos_(pos), |
| 128 compound_bailout_id_(kNoNumber), | 129 binary_operation_(NULL), |
| 130 compound_load_id_(kNoNumber), |
| 131 assignment_id_(GetNextId()), |
| 129 block_start_(false), | 132 block_start_(false), |
| 130 block_end_(false), | 133 block_end_(false), |
| 131 is_monomorphic_(false), | 134 is_monomorphic_(false), |
| 132 receiver_types_(NULL) { | 135 receiver_types_(NULL) { |
| 133 ASSERT(Token::IsAssignmentOp(op)); | 136 ASSERT(Token::IsAssignmentOp(op)); |
| 134 binary_operation_ = is_compound() | |
| 135 ? new BinaryOperation(binary_op(), target, value, pos + 1) | |
| 136 : NULL; | |
| 137 if (is_compound()) { | 137 if (is_compound()) { |
| 138 compound_bailout_id_ = GetNextId(); | 138 binary_operation_ = |
| 139 new BinaryOperation(binary_op(), target, value, pos + 1); |
| 140 compound_load_id_ = GetNextId(); |
| 139 } | 141 } |
| 140 } | 142 } |
| 141 | 143 |
| 142 | 144 |
| 143 Token::Value Assignment::binary_op() const { | 145 Token::Value Assignment::binary_op() const { |
| 144 switch (op_) { | 146 switch (op_) { |
| 145 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
| 146 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 148 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
| 147 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 149 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
| 148 case Token::ASSIGN_SHL: return Token::SHL; | 150 case Token::ASSIGN_SHL: return Token::SHL; |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 compare_type_ = SMI_ONLY; | 553 compare_type_ = SMI_ONLY; |
| 552 } else if (info.IsNonPrimitive()) { | 554 } else if (info.IsNonPrimitive()) { |
| 553 compare_type_ = OBJECT_ONLY; | 555 compare_type_ = OBJECT_ONLY; |
| 554 } else { | 556 } else { |
| 555 ASSERT(compare_type_ == NONE); | 557 ASSERT(compare_type_ == NONE); |
| 556 } | 558 } |
| 557 } | 559 } |
| 558 | 560 |
| 559 | 561 |
| 560 static bool CallWithoutIC(Handle<JSFunction> target, int arity) { | 562 static bool CallWithoutIC(Handle<JSFunction> target, int arity) { |
| 563 SharedFunctionInfo* info = target->shared(); |
| 561 if (target->NeedsArgumentsAdaption()) { | 564 if (target->NeedsArgumentsAdaption()) { |
| 562 // If the number of formal parameters of the target function | 565 // If the number of formal parameters of the target function |
| 563 // does not match the number of arguments we're passing, we | 566 // does not match the number of arguments we're passing, we |
| 564 // don't want to deal with it. | 567 // don't want to deal with it. |
| 565 return target->shared()->formal_parameter_count() == arity; | 568 return info->formal_parameter_count() == arity; |
| 566 } else { | 569 } else { |
| 567 // If the target doesn't need arguments adaption, we can call | 570 // If the target doesn't need arguments adaption, we can call |
| 568 // it directly, but we avoid to do so if it has a custom call | 571 // it directly, but we avoid to do so if it has a custom call |
| 569 // generator, because that is likely to generate better code. | 572 // generator, because that is likely to generate better code. |
| 570 return !target->shared()->HasCustomCallGenerator(); | 573 return !info->HasBuiltinFunctionId() || |
| 574 !CallStubCompiler::HasCustomCallGenerator(info->builtin_function_id()); |
| 571 } | 575 } |
| 572 } | 576 } |
| 573 | 577 |
| 574 | 578 |
| 575 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { | 579 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { |
| 576 holder_ = Handle<JSObject>::null(); | 580 holder_ = Handle<JSObject>::null(); |
| 577 while (true) { | 581 while (true) { |
| 578 LookupResult lookup; | 582 LookupResult lookup; |
| 579 type->LookupInDescriptors(NULL, *name, &lookup); | 583 type->LookupInDescriptors(NULL, *name, &lookup); |
| 580 // If the function wasn't found directly in the map, we start | 584 // If the function wasn't found directly in the map, we start |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 | 1038 |
| 1035 CaseClause::CaseClause(Expression* label, | 1039 CaseClause::CaseClause(Expression* label, |
| 1036 ZoneList<Statement*>* statements, | 1040 ZoneList<Statement*>* statements, |
| 1037 int pos) | 1041 int pos) |
| 1038 : label_(label), | 1042 : label_(label), |
| 1039 statements_(statements), | 1043 statements_(statements), |
| 1040 position_(pos), | 1044 position_(pos), |
| 1041 compare_type_(NONE) {} | 1045 compare_type_(NONE) {} |
| 1042 | 1046 |
| 1043 } } // namespace v8::internal | 1047 } } // namespace v8::internal |
| OLD | NEW |