| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 VariableProxy* var_proxy = AsVariableProxy(); | 75 VariableProxy* var_proxy = AsVariableProxy(); |
| 76 if (var_proxy == NULL) return false; | 76 if (var_proxy == NULL) return false; |
| 77 Variable* var = var_proxy->var(); | 77 Variable* var = var_proxy->var(); |
| 78 // The global identifier "undefined" is immutable. Everything | 78 // The global identifier "undefined" is immutable. Everything |
| 79 // else could be reassigned. | 79 // else could be reassigned. |
| 80 return var != NULL && var->location() == Variable::UNALLOCATED && | 80 return var != NULL && var->location() == Variable::UNALLOCATED && |
| 81 var_proxy->name()->Equals(isolate->heap()->undefined_string()); | 81 var_proxy->name()->Equals(isolate->heap()->undefined_string()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 | 84 |
| 85 VariableProxy::VariableProxy(Isolate* isolate, Variable* var, int position) | 85 VariableProxy::VariableProxy(Zone* zone, Variable* var, int position) |
| 86 : Expression(isolate, position), | 86 : Expression(zone, position), |
| 87 name_(var->name()), | 87 name_(var->name()), |
| 88 var_(NULL), // Will be set by the call to BindTo. | 88 var_(NULL), // Will be set by the call to BindTo. |
| 89 is_this_(var->is_this()), | 89 is_this_(var->is_this()), |
| 90 is_trivial_(false), | 90 is_trivial_(false), |
| 91 is_lvalue_(false), | 91 is_lvalue_(false), |
| 92 interface_(var->interface()) { | 92 interface_(var->interface()) { |
| 93 BindTo(var); | 93 BindTo(var); |
| 94 } | 94 } |
| 95 | 95 |
| 96 | 96 |
| 97 VariableProxy::VariableProxy(Isolate* isolate, | 97 VariableProxy::VariableProxy(Zone* zone, |
| 98 Handle<String> name, | 98 Handle<String> name, |
| 99 bool is_this, | 99 bool is_this, |
| 100 Interface* interface, | 100 Interface* interface, |
| 101 int position) | 101 int position) |
| 102 : Expression(isolate, position), | 102 : Expression(zone, position), |
| 103 name_(name), | 103 name_(name), |
| 104 var_(NULL), | 104 var_(NULL), |
| 105 is_this_(is_this), | 105 is_this_(is_this), |
| 106 is_trivial_(false), | 106 is_trivial_(false), |
| 107 is_lvalue_(false), | 107 is_lvalue_(false), |
| 108 interface_(interface) { | 108 interface_(interface) { |
| 109 // Names must be canonicalized for fast equality checks. | 109 // Names must be canonicalized for fast equality checks. |
| 110 ASSERT(name->IsInternalizedString()); | 110 ASSERT(name->IsInternalizedString()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 | 113 |
| 114 void VariableProxy::BindTo(Variable* var) { | 114 void VariableProxy::BindTo(Variable* var) { |
| 115 ASSERT(var_ == NULL); // must be bound only once | 115 ASSERT(var_ == NULL); // must be bound only once |
| 116 ASSERT(var != NULL); // must bind | 116 ASSERT(var != NULL); // must bind |
| 117 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); | 117 ASSERT(!FLAG_harmony_modules || interface_->IsUnified(var->interface())); |
| 118 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); | 118 ASSERT((is_this() && var->is_this()) || name_.is_identical_to(var->name())); |
| 119 // Ideally CONST-ness should match. However, this is very hard to achieve | 119 // Ideally CONST-ness should match. However, this is very hard to achieve |
| 120 // because we don't know the exact semantics of conflicting (const and | 120 // because we don't know the exact semantics of conflicting (const and |
| 121 // non-const) multiple variable declarations, const vars introduced via | 121 // non-const) multiple variable declarations, const vars introduced via |
| 122 // eval() etc. Const-ness and variable declarations are a complete mess | 122 // eval() etc. Const-ness and variable declarations are a complete mess |
| 123 // in JS. Sigh... | 123 // in JS. Sigh... |
| 124 var_ = var; | 124 var_ = var; |
| 125 var->set_is_used(true); | 125 var->set_is_used(true); |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 Assignment::Assignment(Isolate* isolate, | 129 Assignment::Assignment(Zone* zone, |
| 130 Token::Value op, | 130 Token::Value op, |
| 131 Expression* target, | 131 Expression* target, |
| 132 Expression* value, | 132 Expression* value, |
| 133 int pos) | 133 int pos) |
| 134 : Expression(isolate, pos), | 134 : Expression(zone, pos), |
| 135 op_(op), | 135 op_(op), |
| 136 target_(target), | 136 target_(target), |
| 137 value_(value), | 137 value_(value), |
| 138 binary_operation_(NULL), | 138 binary_operation_(NULL), |
| 139 assignment_id_(GetNextId(isolate)), | 139 assignment_id_(GetNextId(zone)), |
| 140 is_uninitialized_(false), | 140 is_uninitialized_(false), |
| 141 is_pre_monomorphic_(false), | 141 is_pre_monomorphic_(false), |
| 142 store_mode_(STANDARD_STORE) { } | 142 store_mode_(STANDARD_STORE) { } |
| 143 | 143 |
| 144 | 144 |
| 145 Token::Value Assignment::binary_op() const { | 145 Token::Value Assignment::binary_op() const { |
| 146 switch (op_) { | 146 switch (op_) { |
| 147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; | 147 case Token::ASSIGN_BIT_OR: return Token::BIT_OR; |
| 148 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; | 148 case Token::ASSIGN_BIT_XOR: return Token::BIT_XOR; |
| 149 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; | 149 case Token::ASSIGN_BIT_AND: return Token::BIT_AND; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); | 196 SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj); |
| 197 if (shared->start_position() == start_position()) { | 197 if (shared->start_position() == start_position()) { |
| 198 shared_info_ = Handle<SharedFunctionInfo>(shared); | 198 shared_info_ = Handle<SharedFunctionInfo>(shared); |
| 199 break; | 199 break; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 | 204 |
| 205 | 205 |
| 206 ObjectLiteralProperty::ObjectLiteralProperty(Literal* key, | 206 ObjectLiteralProperty::ObjectLiteralProperty( |
| 207 Expression* value, | 207 Zone* zone, Literal* key, Expression* value) { |
| 208 Isolate* isolate) { | |
| 209 emit_store_ = true; | 208 emit_store_ = true; |
| 210 key_ = key; | 209 key_ = key; |
| 211 value_ = value; | 210 value_ = value; |
| 212 Object* k = *key->value(); | 211 Object* k = *key->value(); |
| 213 if (k->IsInternalizedString() && | 212 if (k->IsInternalizedString() && |
| 214 isolate->heap()->proto_string()->Equals(String::cast(k))) { | 213 zone->isolate()->heap()->proto_string()->Equals(String::cast(k))) { |
| 215 kind_ = PROTOTYPE; | 214 kind_ = PROTOTYPE; |
| 216 } else if (value_->AsMaterializedLiteral() != NULL) { | 215 } else if (value_->AsMaterializedLiteral() != NULL) { |
| 217 kind_ = MATERIALIZED_LITERAL; | 216 kind_ = MATERIALIZED_LITERAL; |
| 218 } else if (value_->AsLiteral() != NULL) { | 217 } else if (value_->AsLiteral() != NULL) { |
| 219 kind_ = CONSTANT; | 218 kind_ = CONSTANT; |
| 220 } else { | 219 } else { |
| 221 kind_ = COMPUTED; | 220 kind_ = COMPUTED; |
| 222 } | 221 } |
| 223 } | 222 } |
| 224 | 223 |
| 225 | 224 |
| 226 ObjectLiteralProperty::ObjectLiteralProperty(bool is_getter, | 225 ObjectLiteralProperty::ObjectLiteralProperty( |
| 227 FunctionLiteral* value) { | 226 Zone* zone, bool is_getter, FunctionLiteral* value) { |
| 228 emit_store_ = true; | 227 emit_store_ = true; |
| 229 value_ = value; | 228 value_ = value; |
| 230 kind_ = is_getter ? GETTER : SETTER; | 229 kind_ = is_getter ? GETTER : SETTER; |
| 231 } | 230 } |
| 232 | 231 |
| 233 | 232 |
| 234 bool ObjectLiteral::Property::IsCompileTimeValue() { | 233 bool ObjectLiteral::Property::IsCompileTimeValue() { |
| 235 return kind_ == CONSTANT || | 234 return kind_ == CONSTANT || |
| 236 (kind_ == MATERIALIZED_LITERAL && | 235 (kind_ == MATERIALIZED_LITERAL && |
| 237 CompileTimeValue::IsCompileTimeValue(value_)); | 236 CompileTimeValue::IsCompileTimeValue(value_)); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 return false; | 582 return false; |
| 584 } | 583 } |
| 585 | 584 |
| 586 | 585 |
| 587 // ---------------------------------------------------------------------------- | 586 // ---------------------------------------------------------------------------- |
| 588 // Recording of type feedback | 587 // Recording of type feedback |
| 589 | 588 |
| 590 // TODO(rossberg): all RecordTypeFeedback functions should disappear | 589 // TODO(rossberg): all RecordTypeFeedback functions should disappear |
| 591 // once we use the common type field in the AST consistently. | 590 // once we use the common type field in the AST consistently. |
| 592 | 591 |
| 593 | |
| 594 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { | 592 void Expression::RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) { |
| 595 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); | 593 to_boolean_types_ = oracle->ToBooleanTypes(test_id()); |
| 596 } | 594 } |
| 597 | 595 |
| 598 | 596 |
| 597 Call::CallType Call::GetCallType(Isolate* isolate) const { |
| 598 VariableProxy* proxy = expression()->AsVariableProxy(); |
| 599 if (proxy != NULL) { |
| 600 if (proxy->var()->is_possibly_eval(isolate)) { |
| 601 return POSSIBLY_EVAL_CALL; |
| 602 } else if (proxy->var()->IsUnallocated()) { |
| 603 return GLOBAL_CALL; |
| 604 } else if (proxy->var()->IsLookupSlot()) { |
| 605 return LOOKUP_SLOT_CALL; |
| 606 } |
| 607 } |
| 608 |
| 609 Property* property = expression()->AsProperty(); |
| 610 return property != NULL ? PROPERTY_CALL : OTHER_CALL; |
| 611 } |
| 612 |
| 613 |
| 599 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { | 614 bool Call::ComputeTarget(Handle<Map> type, Handle<String> name) { |
| 600 // If there is an interceptor, we can't compute the target for a direct call. | 615 // If there is an interceptor, we can't compute the target for a direct call. |
| 601 if (type->has_named_interceptor()) return false; | 616 if (type->has_named_interceptor()) return false; |
| 602 | 617 |
| 603 if (check_type_ == RECEIVER_MAP_CHECK) { | 618 if (check_type_ == RECEIVER_MAP_CHECK) { |
| 604 // For primitive checks the holder is set up to point to the corresponding | 619 // For primitive checks the holder is set up to point to the corresponding |
| 605 // prototype object, i.e. one step of the algorithm below has been already | 620 // prototype object, i.e. one step of the algorithm below has been already |
| 606 // performed. For non-primitive checks we clear it to allow computing | 621 // performed. For non-primitive checks we clear it to allow computing |
| 607 // targets for polymorphic calls. | 622 // targets for polymorphic calls. |
| 608 holder_ = Handle<JSObject>::null(); | 623 holder_ = Handle<JSObject>::null(); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 } else { | 748 } else { |
| 734 if (is_monomorphic_) { | 749 if (is_monomorphic_) { |
| 735 keyed_array_call_is_holey_ = | 750 keyed_array_call_is_holey_ = |
| 736 oracle->KeyedArrayCallIsHoley(CallFeedbackId()); | 751 oracle->KeyedArrayCallIsHoley(CallFeedbackId()); |
| 737 } | 752 } |
| 738 } | 753 } |
| 739 } | 754 } |
| 740 | 755 |
| 741 | 756 |
| 742 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 757 void CallNew::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 743 allocation_info_cell_ = | 758 allocation_site_ = |
| 744 oracle->GetCallNewAllocationInfoCell(CallNewFeedbackId()); | 759 oracle->GetCallNewAllocationSite(CallNewFeedbackId()); |
| 745 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId()); | 760 is_monomorphic_ = oracle->CallNewIsMonomorphic(CallNewFeedbackId()); |
| 746 if (is_monomorphic_) { | 761 if (is_monomorphic_) { |
| 747 target_ = oracle->GetCallNewTarget(CallNewFeedbackId()); | 762 target_ = oracle->GetCallNewTarget(CallNewFeedbackId()); |
| 748 Object* value = allocation_info_cell_->value(); | 763 if (!allocation_site_.is_null()) { |
| 749 ASSERT(!value->IsTheHole()); | 764 elements_kind_ = allocation_site_->GetElementsKind(); |
| 750 if (value->IsAllocationSite()) { | |
| 751 AllocationSite* site = AllocationSite::cast(value); | |
| 752 elements_kind_ = site->GetElementsKind(); | |
| 753 } | 765 } |
| 754 } | 766 } |
| 755 } | 767 } |
| 756 | 768 |
| 757 | 769 |
| 758 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { | 770 void ObjectLiteral::Property::RecordTypeFeedback(TypeFeedbackOracle* oracle) { |
| 759 TypeFeedbackId id = key()->LiteralFeedbackId(); | 771 TypeFeedbackId id = key()->LiteralFeedbackId(); |
| 760 SmallMapList maps; | 772 SmallMapList maps; |
| 761 oracle->CollectReceiverTypes(id, &maps); | 773 oracle->CollectReceiverTypes(id, &maps); |
| 762 receiver_type_ = maps.length() == 1 ? maps.at(0) | 774 receiver_type_ = maps.length() == 1 ? maps.at(0) |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1126 for (int i = 0; i < nodes->length(); i++) { | 1138 for (int i = 0; i < nodes->length(); i++) { |
| 1127 RegExpTree* node = nodes->at(i); | 1139 RegExpTree* node = nodes->at(i); |
| 1128 int node_min_match = node->min_match(); | 1140 int node_min_match = node->min_match(); |
| 1129 min_match_ = IncreaseBy(min_match_, node_min_match); | 1141 min_match_ = IncreaseBy(min_match_, node_min_match); |
| 1130 int node_max_match = node->max_match(); | 1142 int node_max_match = node->max_match(); |
| 1131 max_match_ = IncreaseBy(max_match_, node_max_match); | 1143 max_match_ = IncreaseBy(max_match_, node_max_match); |
| 1132 } | 1144 } |
| 1133 } | 1145 } |
| 1134 | 1146 |
| 1135 | 1147 |
| 1136 CaseClause::CaseClause(Isolate* isolate, | 1148 CaseClause::CaseClause(Zone* zone, |
| 1137 Expression* label, | 1149 Expression* label, |
| 1138 ZoneList<Statement*>* statements, | 1150 ZoneList<Statement*>* statements, |
| 1139 int pos) | 1151 int pos) |
| 1140 : Expression(isolate, pos), | 1152 : Expression(zone, pos), |
| 1141 label_(label), | 1153 label_(label), |
| 1142 statements_(statements), | 1154 statements_(statements), |
| 1143 compare_type_(Type::None(isolate)), | 1155 compare_type_(Type::None(zone)), |
| 1144 compare_id_(AstNode::GetNextId(isolate)), | 1156 compare_id_(AstNode::GetNextId(zone)), |
| 1145 entry_id_(AstNode::GetNextId(isolate)) { | 1157 entry_id_(AstNode::GetNextId(zone)) { |
| 1146 } | 1158 } |
| 1147 | 1159 |
| 1148 | 1160 |
| 1149 #define REGULAR_NODE(NodeType) \ | 1161 #define REGULAR_NODE(NodeType) \ |
| 1150 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1162 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1151 increase_node_count(); \ | 1163 increase_node_count(); \ |
| 1152 } | 1164 } |
| 1153 #define DONT_OPTIMIZE_NODE(NodeType) \ | 1165 #define DONT_OPTIMIZE_NODE(NodeType) \ |
| 1154 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ | 1166 void AstConstructionVisitor::Visit##NodeType(NodeType* node) { \ |
| 1155 increase_node_count(); \ | 1167 increase_node_count(); \ |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1261 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); | 1273 OS::SNPrintF(buffer, "%d", Smi::cast(*value_)->value()); |
| 1262 str = arr; | 1274 str = arr; |
| 1263 } else { | 1275 } else { |
| 1264 str = DoubleToCString(value_->Number(), buffer); | 1276 str = DoubleToCString(value_->Number(), buffer); |
| 1265 } | 1277 } |
| 1266 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); | 1278 return isolate_->factory()->NewStringFromAscii(CStrVector(str)); |
| 1267 } | 1279 } |
| 1268 | 1280 |
| 1269 | 1281 |
| 1270 } } // namespace v8::internal | 1282 } } // namespace v8::internal |
| OLD | NEW |