| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/compiler/ast-graph-builder.h" | 5 #include "src/compiler/ast-graph-builder.h" |
| 6 | 6 |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/control-builders.h" | 8 #include "src/compiler/control-builders.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties-inl.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 Operator* op = common()->Parameter(info()->num_parameters() + 1); | 46 Operator* op = common()->Parameter(info()->num_parameters() + 1); |
| 47 Node* node = NewNode(op); | 47 Node* node = NewNode(op); |
| 48 function_context_.set(node); | 48 function_context_.set(node); |
| 49 } | 49 } |
| 50 return function_context_.get(); | 50 return function_context_.get(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 | 53 |
| 54 bool AstGraphBuilder::CreateGraph() { | 54 bool AstGraphBuilder::CreateGraph() { |
| 55 Scope* scope = info()->scope(); | 55 Scope* scope = info()->scope(); |
| 56 ASSERT(graph() != NULL); | 56 DCHECK(graph() != NULL); |
| 57 | 57 |
| 58 SourcePositionTable::Scope start_pos( | 58 SourcePositionTable::Scope start_pos( |
| 59 source_positions(), | 59 source_positions(), |
| 60 SourcePosition(info()->shared_info()->start_position())); | 60 SourcePosition(info()->shared_info()->start_position())); |
| 61 | 61 |
| 62 // Set up the basic structure of the graph. | 62 // Set up the basic structure of the graph. |
| 63 graph()->SetStart(graph()->NewNode(common()->Start())); | 63 graph()->SetStart(graph()->NewNode(common()->Start())); |
| 64 | 64 |
| 65 // Initialize the top-level environment. | 65 // Initialize the top-level environment. |
| 66 Environment env(this, scope, graph()->start()); | 66 Environment env(this, scope, graph()->start()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 } | 120 } |
| 121 | 121 |
| 122 | 122 |
| 123 // Left-hand side can only be a property, a global or a variable slot. | 123 // Left-hand side can only be a property, a global or a variable slot. |
| 124 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 124 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 125 | 125 |
| 126 | 126 |
| 127 // Determine the left-hand side kind of an assignment. | 127 // Determine the left-hand side kind of an assignment. |
| 128 static LhsKind DetermineLhsKind(Expression* expr) { | 128 static LhsKind DetermineLhsKind(Expression* expr) { |
| 129 Property* property = expr->AsProperty(); | 129 Property* property = expr->AsProperty(); |
| 130 ASSERT(expr->IsValidReferenceExpression()); | 130 DCHECK(expr->IsValidReferenceExpression()); |
| 131 LhsKind lhs_kind = | 131 LhsKind lhs_kind = |
| 132 (property == NULL) ? VARIABLE : (property->key()->IsPropertyName()) | 132 (property == NULL) ? VARIABLE : (property->key()->IsPropertyName()) |
| 133 ? NAMED_PROPERTY | 133 ? NAMED_PROPERTY |
| 134 : KEYED_PROPERTY; | 134 : KEYED_PROPERTY; |
| 135 return lhs_kind; | 135 return lhs_kind; |
| 136 } | 136 } |
| 137 | 137 |
| 138 | 138 |
| 139 // Helper to find an existing shared function info in the baseline code for the | 139 // Helper to find an existing shared function info in the baseline code for the |
| 140 // given function literal. Used to canonicalize SharedFunctionInfo objects. | 140 // given function literal. Used to canonicalize SharedFunctionInfo objects. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 167 Node* control_dependency) | 167 Node* control_dependency) |
| 168 : StructuredGraphBuilder::Environment(builder, control_dependency), | 168 : StructuredGraphBuilder::Environment(builder, control_dependency), |
| 169 parameters_count_(scope->num_parameters() + 1), | 169 parameters_count_(scope->num_parameters() + 1), |
| 170 locals_count_(scope->num_stack_slots()), | 170 locals_count_(scope->num_stack_slots()), |
| 171 parameters_node_(NULL), | 171 parameters_node_(NULL), |
| 172 locals_node_(NULL), | 172 locals_node_(NULL), |
| 173 stack_node_(NULL), | 173 stack_node_(NULL), |
| 174 parameters_dirty_(false), | 174 parameters_dirty_(false), |
| 175 locals_dirty_(false), | 175 locals_dirty_(false), |
| 176 stack_dirty_(false) { | 176 stack_dirty_(false) { |
| 177 ASSERT_EQ(scope->num_parameters() + 1, parameters_count()); | 177 DCHECK_EQ(scope->num_parameters() + 1, parameters_count()); |
| 178 | 178 |
| 179 // Bind the receiver variable. | 179 // Bind the receiver variable. |
| 180 Node* receiver = builder->graph()->NewNode(common()->Parameter(0)); | 180 Node* receiver = builder->graph()->NewNode(common()->Parameter(0)); |
| 181 values()->push_back(receiver); | 181 values()->push_back(receiver); |
| 182 | 182 |
| 183 // Bind all parameter variables. The parameter indices are shifted by 1 | 183 // Bind all parameter variables. The parameter indices are shifted by 1 |
| 184 // (receiver is parameter index -1 but environment index 0). | 184 // (receiver is parameter index -1 but environment index 0). |
| 185 for (int i = 0; i < scope->num_parameters(); ++i) { | 185 for (int i = 0; i < scope->num_parameters(); ++i) { |
| 186 Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1)); | 186 Node* parameter = builder->graph()->NewNode(common()->Parameter(i + 1)); |
| 187 values()->push_back(parameter); | 187 values()->push_back(parameter); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 #endif | 235 #endif |
| 236 } | 236 } |
| 237 | 237 |
| 238 | 238 |
| 239 AstGraphBuilder::AstContext::~AstContext() { | 239 AstGraphBuilder::AstContext::~AstContext() { |
| 240 owner()->set_ast_context(outer_); // Pop. | 240 owner()->set_ast_context(outer_); // Pop. |
| 241 } | 241 } |
| 242 | 242 |
| 243 | 243 |
| 244 AstGraphBuilder::AstEffectContext::~AstEffectContext() { | 244 AstGraphBuilder::AstEffectContext::~AstEffectContext() { |
| 245 ASSERT(environment()->stack_height() == original_height_); | 245 DCHECK(environment()->stack_height() == original_height_); |
| 246 } | 246 } |
| 247 | 247 |
| 248 | 248 |
| 249 AstGraphBuilder::AstValueContext::~AstValueContext() { | 249 AstGraphBuilder::AstValueContext::~AstValueContext() { |
| 250 ASSERT(environment()->stack_height() == original_height_ + 1); | 250 DCHECK(environment()->stack_height() == original_height_ + 1); |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 AstGraphBuilder::AstTestContext::~AstTestContext() { | 254 AstGraphBuilder::AstTestContext::~AstTestContext() { |
| 255 ASSERT(environment()->stack_height() == original_height_ + 1); | 255 DCHECK(environment()->stack_height() == original_height_ + 1); |
| 256 } | 256 } |
| 257 | 257 |
| 258 | 258 |
| 259 void AstGraphBuilder::AstEffectContext::ProduceValue(Node* value) { | 259 void AstGraphBuilder::AstEffectContext::ProduceValue(Node* value) { |
| 260 // The value is ignored. | 260 // The value is ignored. |
| 261 } | 261 } |
| 262 | 262 |
| 263 | 263 |
| 264 void AstGraphBuilder::AstValueContext::ProduceValue(Node* value) { | 264 void AstGraphBuilder::AstValueContext::ProduceValue(Node* value) { |
| 265 environment()->Push(value); | 265 environment()->Push(value); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 284 } | 284 } |
| 285 | 285 |
| 286 | 286 |
| 287 AstGraphBuilder::BreakableScope* AstGraphBuilder::BreakableScope::FindBreakable( | 287 AstGraphBuilder::BreakableScope* AstGraphBuilder::BreakableScope::FindBreakable( |
| 288 BreakableStatement* target) { | 288 BreakableStatement* target) { |
| 289 BreakableScope* current = this; | 289 BreakableScope* current = this; |
| 290 while (current != NULL && current->target_ != target) { | 290 while (current != NULL && current->target_ != target) { |
| 291 owner_->environment()->Drop(current->drop_extra_); | 291 owner_->environment()->Drop(current->drop_extra_); |
| 292 current = current->next_; | 292 current = current->next_; |
| 293 } | 293 } |
| 294 ASSERT(current != NULL); // Always found (unless stack is malformed). | 294 DCHECK(current != NULL); // Always found (unless stack is malformed). |
| 295 return current; | 295 return current; |
| 296 } | 296 } |
| 297 | 297 |
| 298 | 298 |
| 299 void AstGraphBuilder::BreakableScope::BreakTarget(BreakableStatement* stmt) { | 299 void AstGraphBuilder::BreakableScope::BreakTarget(BreakableStatement* stmt) { |
| 300 FindBreakable(stmt)->control_->Break(); | 300 FindBreakable(stmt)->control_->Break(); |
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 void AstGraphBuilder::BreakableScope::ContinueTarget(BreakableStatement* stmt) { | 304 void AstGraphBuilder::BreakableScope::ContinueTarget(BreakableStatement* stmt) { |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 AccessorTable accessor_table(zone()); | 868 AccessorTable accessor_table(zone()); |
| 869 for (int i = 0; i < expr->properties()->length(); i++) { | 869 for (int i = 0; i < expr->properties()->length(); i++) { |
| 870 ObjectLiteral::Property* property = expr->properties()->at(i); | 870 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 871 if (property->IsCompileTimeValue()) continue; | 871 if (property->IsCompileTimeValue()) continue; |
| 872 | 872 |
| 873 Literal* key = property->key(); | 873 Literal* key = property->key(); |
| 874 switch (property->kind()) { | 874 switch (property->kind()) { |
| 875 case ObjectLiteral::Property::CONSTANT: | 875 case ObjectLiteral::Property::CONSTANT: |
| 876 UNREACHABLE(); | 876 UNREACHABLE(); |
| 877 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 877 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 878 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); | 878 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
| 879 // Fall through. | 879 // Fall through. |
| 880 case ObjectLiteral::Property::COMPUTED: { | 880 case ObjectLiteral::Property::COMPUTED: { |
| 881 // It is safe to use [[Put]] here because the boilerplate already | 881 // It is safe to use [[Put]] here because the boilerplate already |
| 882 // contains computed properties with an uninitialized value. | 882 // contains computed properties with an uninitialized value. |
| 883 if (key->value()->IsInternalizedString()) { | 883 if (key->value()->IsInternalizedString()) { |
| 884 if (property->emit_store()) { | 884 if (property->emit_store()) { |
| 885 VisitForValue(property->value()); | 885 VisitForValue(property->value()); |
| 886 Node* value = environment()->Pop(); | 886 Node* value = environment()->Pop(); |
| 887 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); | 887 PrintableUnique<Name> name = MakeUnique(key->AsPropertyName()); |
| 888 NewNode(javascript()->StoreNamed(name), literal, value); | 888 NewNode(javascript()->StoreNamed(name), literal, value); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 978 Node* index = jsgraph()->Constant(i); | 978 Node* index = jsgraph()->Constant(i); |
| 979 NewNode(javascript()->StoreProperty(), literal, index, value); | 979 NewNode(javascript()->StoreProperty(), literal, index, value); |
| 980 } | 980 } |
| 981 | 981 |
| 982 environment()->Pop(); // Array literal index. | 982 environment()->Pop(); // Array literal index. |
| 983 ast_context()->ProduceValue(environment()->Pop()); | 983 ast_context()->ProduceValue(environment()->Pop()); |
| 984 } | 984 } |
| 985 | 985 |
| 986 | 986 |
| 987 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { | 987 void AstGraphBuilder::VisitForInAssignment(Expression* expr, Node* value) { |
| 988 ASSERT(expr->IsValidReferenceExpression()); | 988 DCHECK(expr->IsValidReferenceExpression()); |
| 989 | 989 |
| 990 // Left-hand side can only be a property, a global or a variable slot. | 990 // Left-hand side can only be a property, a global or a variable slot. |
| 991 Property* property = expr->AsProperty(); | 991 Property* property = expr->AsProperty(); |
| 992 LhsKind assign_type = DetermineLhsKind(expr); | 992 LhsKind assign_type = DetermineLhsKind(expr); |
| 993 | 993 |
| 994 // Evaluate LHS expression and store the value. | 994 // Evaluate LHS expression and store the value. |
| 995 switch (assign_type) { | 995 switch (assign_type) { |
| 996 case VARIABLE: { | 996 case VARIABLE: { |
| 997 Variable* var = expr->AsVariableProxy()->var(); | 997 Variable* var = expr->AsVariableProxy()->var(); |
| 998 BuildVariableAssignment(var, value, Token::ASSIGN); | 998 BuildVariableAssignment(var, value, Token::ASSIGN); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1016 Node* object = environment()->Pop(); | 1016 Node* object = environment()->Pop(); |
| 1017 value = environment()->Pop(); | 1017 value = environment()->Pop(); |
| 1018 NewNode(javascript()->StoreProperty(), object, key, value); | 1018 NewNode(javascript()->StoreProperty(), object, key, value); |
| 1019 break; | 1019 break; |
| 1020 } | 1020 } |
| 1021 } | 1021 } |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 | 1024 |
| 1025 void AstGraphBuilder::VisitAssignment(Assignment* expr) { | 1025 void AstGraphBuilder::VisitAssignment(Assignment* expr) { |
| 1026 ASSERT(expr->target()->IsValidReferenceExpression()); | 1026 DCHECK(expr->target()->IsValidReferenceExpression()); |
| 1027 | 1027 |
| 1028 // Left-hand side can only be a property, a global or a variable slot. | 1028 // Left-hand side can only be a property, a global or a variable slot. |
| 1029 Property* property = expr->target()->AsProperty(); | 1029 Property* property = expr->target()->AsProperty(); |
| 1030 LhsKind assign_type = DetermineLhsKind(expr->target()); | 1030 LhsKind assign_type = DetermineLhsKind(expr->target()); |
| 1031 | 1031 |
| 1032 // Evaluate LHS expression. | 1032 // Evaluate LHS expression. |
| 1033 switch (assign_type) { | 1033 switch (assign_type) { |
| 1034 case VARIABLE: | 1034 case VARIABLE: |
| 1035 // Nothing to do here. | 1035 // Nothing to do here. |
| 1036 break; | 1036 break; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1155 bool possibly_eval = false; | 1155 bool possibly_eval = false; |
| 1156 switch (call_type) { | 1156 switch (call_type) { |
| 1157 case Call::GLOBAL_CALL: { | 1157 case Call::GLOBAL_CALL: { |
| 1158 Variable* variable = callee->AsVariableProxy()->var(); | 1158 Variable* variable = callee->AsVariableProxy()->var(); |
| 1159 callee_value = BuildVariableLoad(variable); | 1159 callee_value = BuildVariableLoad(variable); |
| 1160 receiver_value = jsgraph()->UndefinedConstant(); | 1160 receiver_value = jsgraph()->UndefinedConstant(); |
| 1161 break; | 1161 break; |
| 1162 } | 1162 } |
| 1163 case Call::LOOKUP_SLOT_CALL: { | 1163 case Call::LOOKUP_SLOT_CALL: { |
| 1164 Variable* variable = callee->AsVariableProxy()->var(); | 1164 Variable* variable = callee->AsVariableProxy()->var(); |
| 1165 ASSERT(variable->location() == Variable::LOOKUP); | 1165 DCHECK(variable->location() == Variable::LOOKUP); |
| 1166 Node* name = jsgraph()->Constant(variable->name()); | 1166 Node* name = jsgraph()->Constant(variable->name()); |
| 1167 Operator* op = javascript()->Runtime(Runtime::kLoadLookupSlot, 2); | 1167 Operator* op = javascript()->Runtime(Runtime::kLoadLookupSlot, 2); |
| 1168 Node* pair = NewNode(op, current_context(), name); | 1168 Node* pair = NewNode(op, current_context(), name); |
| 1169 callee_value = NewNode(common()->Projection(0), pair); | 1169 callee_value = NewNode(common()->Projection(0), pair); |
| 1170 receiver_value = NewNode(common()->Projection(1), pair); | 1170 receiver_value = NewNode(common()->Projection(1), pair); |
| 1171 break; | 1171 break; |
| 1172 } | 1172 } |
| 1173 case Call::PROPERTY_CALL: { | 1173 case Call::PROPERTY_CALL: { |
| 1174 Property* property = callee->AsProperty(); | 1174 Property* property = callee->AsProperty(); |
| 1175 VisitForValue(property->obj()); | 1175 VisitForValue(property->obj()); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 ast_context()->ProduceValue(value); | 1277 ast_context()->ProduceValue(value); |
| 1278 } | 1278 } |
| 1279 | 1279 |
| 1280 | 1280 |
| 1281 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { | 1281 void AstGraphBuilder::VisitCallRuntime(CallRuntime* expr) { |
| 1282 const Runtime::Function* function = expr->function(); | 1282 const Runtime::Function* function = expr->function(); |
| 1283 | 1283 |
| 1284 // Handle calls to runtime functions implemented in JavaScript separately as | 1284 // Handle calls to runtime functions implemented in JavaScript separately as |
| 1285 // the call follows JavaScript ABI and the callee is statically unknown. | 1285 // the call follows JavaScript ABI and the callee is statically unknown. |
| 1286 if (expr->is_jsruntime()) { | 1286 if (expr->is_jsruntime()) { |
| 1287 ASSERT(function == NULL && expr->name()->length() > 0); | 1287 DCHECK(function == NULL && expr->name()->length() > 0); |
| 1288 return VisitCallJSRuntime(expr); | 1288 return VisitCallJSRuntime(expr); |
| 1289 } | 1289 } |
| 1290 | 1290 |
| 1291 // Evaluate all arguments to the runtime call. | 1291 // Evaluate all arguments to the runtime call. |
| 1292 ZoneList<Expression*>* args = expr->arguments(); | 1292 ZoneList<Expression*>* args = expr->arguments(); |
| 1293 VisitForValues(args); | 1293 VisitForValues(args); |
| 1294 | 1294 |
| 1295 // Create node to perform the runtime call. | 1295 // Create node to perform the runtime call. |
| 1296 Runtime::FunctionId functionId = function->function_id; | 1296 Runtime::FunctionId functionId = function->function_id; |
| 1297 Operator* call = javascript()->Runtime(functionId, args->length()); | 1297 Operator* call = javascript()->Runtime(functionId, args->length()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1312 return VisitTypeof(expr); | 1312 return VisitTypeof(expr); |
| 1313 case Token::NOT: | 1313 case Token::NOT: |
| 1314 return VisitNot(expr); | 1314 return VisitNot(expr); |
| 1315 default: | 1315 default: |
| 1316 UNREACHABLE(); | 1316 UNREACHABLE(); |
| 1317 } | 1317 } |
| 1318 } | 1318 } |
| 1319 | 1319 |
| 1320 | 1320 |
| 1321 void AstGraphBuilder::VisitCountOperation(CountOperation* expr) { | 1321 void AstGraphBuilder::VisitCountOperation(CountOperation* expr) { |
| 1322 ASSERT(expr->expression()->IsValidReferenceExpression()); | 1322 DCHECK(expr->expression()->IsValidReferenceExpression()); |
| 1323 | 1323 |
| 1324 // Left-hand side can only be a property, a global or a variable slot. | 1324 // Left-hand side can only be a property, a global or a variable slot. |
| 1325 Property* property = expr->expression()->AsProperty(); | 1325 Property* property = expr->expression()->AsProperty(); |
| 1326 LhsKind assign_type = DetermineLhsKind(expr->expression()); | 1326 LhsKind assign_type = DetermineLhsKind(expr->expression()); |
| 1327 | 1327 |
| 1328 // Reserve space for result of postfix operation. | 1328 // Reserve space for result of postfix operation. |
| 1329 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); | 1329 bool is_postfix = expr->is_postfix() && !ast_context()->IsEffect(); |
| 1330 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); | 1330 if (is_postfix) environment()->Push(jsgraph()->UndefinedConstant()); |
| 1331 | 1331 |
| 1332 // Evaluate LHS expression and get old value. | 1332 // Evaluate LHS expression and get old value. |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 void AstGraphBuilder::VisitThisFunction(ThisFunction* expr) { | 1466 void AstGraphBuilder::VisitThisFunction(ThisFunction* expr) { |
| 1467 Node* value = GetFunctionClosure(); | 1467 Node* value = GetFunctionClosure(); |
| 1468 ast_context()->ProduceValue(value); | 1468 ast_context()->ProduceValue(value); |
| 1469 } | 1469 } |
| 1470 | 1470 |
| 1471 | 1471 |
| 1472 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { UNREACHABLE(); } | 1472 void AstGraphBuilder::VisitCaseClause(CaseClause* expr) { UNREACHABLE(); } |
| 1473 | 1473 |
| 1474 | 1474 |
| 1475 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { | 1475 void AstGraphBuilder::VisitDeclarations(ZoneList<Declaration*>* declarations) { |
| 1476 ASSERT(globals()->is_empty()); | 1476 DCHECK(globals()->is_empty()); |
| 1477 AstVisitor::VisitDeclarations(declarations); | 1477 AstVisitor::VisitDeclarations(declarations); |
| 1478 if (globals()->is_empty()) return; | 1478 if (globals()->is_empty()) return; |
| 1479 Handle<FixedArray> data = | 1479 Handle<FixedArray> data = |
| 1480 isolate()->factory()->NewFixedArray(globals()->length(), TENURED); | 1480 isolate()->factory()->NewFixedArray(globals()->length(), TENURED); |
| 1481 for (int i = 0; i < globals()->length(); ++i) data->set(i, *globals()->at(i)); | 1481 for (int i = 0; i < globals()->length(); ++i) data->set(i, *globals()->at(i)); |
| 1482 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | | 1482 int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) | |
| 1483 DeclareGlobalsNativeFlag::encode(info()->is_native()) | | 1483 DeclareGlobalsNativeFlag::encode(info()->is_native()) | |
| 1484 DeclareGlobalsStrictMode::encode(info()->strict_mode()); | 1484 DeclareGlobalsStrictMode::encode(info()->strict_mode()); |
| 1485 Node* flags = jsgraph()->Constant(encoded_flags); | 1485 Node* flags = jsgraph()->Constant(encoded_flags); |
| 1486 Node* pairs = jsgraph()->Constant(data); | 1486 Node* pairs = jsgraph()->Constant(data); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1502 Visit(stmt->body()); | 1502 Visit(stmt->body()); |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 | 1505 |
| 1506 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { | 1506 void AstGraphBuilder::VisitDelete(UnaryOperation* expr) { |
| 1507 Node* value; | 1507 Node* value; |
| 1508 if (expr->expression()->IsVariableProxy()) { | 1508 if (expr->expression()->IsVariableProxy()) { |
| 1509 // Delete of an unqualified identifier is only allowed in classic mode but | 1509 // Delete of an unqualified identifier is only allowed in classic mode but |
| 1510 // deleting "this" is allowed in all language modes. | 1510 // deleting "this" is allowed in all language modes. |
| 1511 Variable* variable = expr->expression()->AsVariableProxy()->var(); | 1511 Variable* variable = expr->expression()->AsVariableProxy()->var(); |
| 1512 ASSERT(strict_mode() == SLOPPY || variable->is_this()); | 1512 DCHECK(strict_mode() == SLOPPY || variable->is_this()); |
| 1513 value = BuildVariableDelete(variable); | 1513 value = BuildVariableDelete(variable); |
| 1514 } else if (expr->expression()->IsProperty()) { | 1514 } else if (expr->expression()->IsProperty()) { |
| 1515 Property* property = expr->expression()->AsProperty(); | 1515 Property* property = expr->expression()->AsProperty(); |
| 1516 VisitForValue(property->obj()); | 1516 VisitForValue(property->obj()); |
| 1517 VisitForValue(property->key()); | 1517 VisitForValue(property->key()); |
| 1518 Node* key = environment()->Pop(); | 1518 Node* key = environment()->Pop(); |
| 1519 Node* object = environment()->Pop(); | 1519 Node* object = environment()->Pop(); |
| 1520 value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key); | 1520 value = NewNode(javascript()->DeleteProperty(strict_mode()), object, key); |
| 1521 } else { | 1521 } else { |
| 1522 VisitForEffect(expr->expression()); | 1522 VisitForEffect(expr->expression()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1584 Visit(expr->right()); | 1584 Visit(expr->right()); |
| 1585 } else if (ast_context()->IsEffect()) { | 1585 } else if (ast_context()->IsEffect()) { |
| 1586 environment()->Pop(); | 1586 environment()->Pop(); |
| 1587 } | 1587 } |
| 1588 compare_if.End(); | 1588 compare_if.End(); |
| 1589 ast_context()->ReplaceValue(); | 1589 ast_context()->ReplaceValue(); |
| 1590 } | 1590 } |
| 1591 | 1591 |
| 1592 | 1592 |
| 1593 Node* AstGraphBuilder::ProcessArguments(Operator* op, int arity) { | 1593 Node* AstGraphBuilder::ProcessArguments(Operator* op, int arity) { |
| 1594 ASSERT(environment()->stack_height() >= arity); | 1594 DCHECK(environment()->stack_height() >= arity); |
| 1595 Node** all = info()->zone()->NewArray<Node*>(arity); // XXX: alloca? | 1595 Node** all = info()->zone()->NewArray<Node*>(arity); // XXX: alloca? |
| 1596 for (int i = arity - 1; i >= 0; --i) { | 1596 for (int i = arity - 1; i >= 0; --i) { |
| 1597 all[i] = environment()->Pop(); | 1597 all[i] = environment()->Pop(); |
| 1598 } | 1598 } |
| 1599 Node* value = NewNode(op, arity, all); | 1599 Node* value = NewNode(op, arity, all); |
| 1600 return value; | 1600 return value; |
| 1601 } | 1601 } |
| 1602 | 1602 |
| 1603 | 1603 |
| 1604 Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) { | 1604 Node* AstGraphBuilder::BuildLocalFunctionContext(Node* context, Node* closure) { |
| 1605 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 1605 int heap_slots = info()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 1606 if (heap_slots <= 0) return context; | 1606 if (heap_slots <= 0) return context; |
| 1607 set_current_context(context); | 1607 set_current_context(context); |
| 1608 | 1608 |
| 1609 // Allocate a new local context. | 1609 // Allocate a new local context. |
| 1610 Operator* op = javascript()->CreateFunctionContext(); | 1610 Operator* op = javascript()->CreateFunctionContext(); |
| 1611 Node* local_context = NewNode(op, closure); | 1611 Node* local_context = NewNode(op, closure); |
| 1612 set_current_context(local_context); | 1612 set_current_context(local_context); |
| 1613 | 1613 |
| 1614 // Copy parameters into context if necessary. | 1614 // Copy parameters into context if necessary. |
| 1615 int num_parameters = info()->scope()->num_parameters(); | 1615 int num_parameters = info()->scope()->num_parameters(); |
| 1616 for (int i = 0; i < num_parameters; i++) { | 1616 for (int i = 0; i < num_parameters; i++) { |
| 1617 Variable* variable = info()->scope()->parameter(i); | 1617 Variable* variable = info()->scope()->parameter(i); |
| 1618 if (!variable->IsContextSlot()) continue; | 1618 if (!variable->IsContextSlot()) continue; |
| 1619 // Temporary parameter node. The parameter indices are shifted by 1 | 1619 // Temporary parameter node. The parameter indices are shifted by 1 |
| 1620 // (receiver is parameter index -1 but environment index 0). | 1620 // (receiver is parameter index -1 but environment index 0). |
| 1621 Node* parameter = NewNode(common()->Parameter(i + 1)); | 1621 Node* parameter = NewNode(common()->Parameter(i + 1)); |
| 1622 // Context variable (at bottom of the context chain). | 1622 // Context variable (at bottom of the context chain). |
| 1623 ASSERT_EQ(0, info()->scope()->ContextChainLength(variable->scope())); | 1623 DCHECK_EQ(0, info()->scope()->ContextChainLength(variable->scope())); |
| 1624 Operator* op = javascript()->StoreContext(0, variable->index()); | 1624 Operator* op = javascript()->StoreContext(0, variable->index()); |
| 1625 NewNode(op, local_context, parameter); | 1625 NewNode(op, local_context, parameter); |
| 1626 } | 1626 } |
| 1627 | 1627 |
| 1628 return local_context; | 1628 return local_context; |
| 1629 } | 1629 } |
| 1630 | 1630 |
| 1631 | 1631 |
| 1632 Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) { | 1632 Node* AstGraphBuilder::BuildArgumentsObject(Variable* arguments) { |
| 1633 if (arguments == NULL) return NULL; | 1633 if (arguments == NULL) return NULL; |
| 1634 | 1634 |
| 1635 // Allocate and initialize a new arguments object. | 1635 // Allocate and initialize a new arguments object. |
| 1636 Node* callee = GetFunctionClosure(); | 1636 Node* callee = GetFunctionClosure(); |
| 1637 Operator* op = javascript()->Runtime(Runtime::kNewArguments, 1); | 1637 Operator* op = javascript()->Runtime(Runtime::kNewArguments, 1); |
| 1638 Node* object = NewNode(op, callee); | 1638 Node* object = NewNode(op, callee); |
| 1639 | 1639 |
| 1640 // Assign the object to the arguments variable. | 1640 // Assign the object to the arguments variable. |
| 1641 ASSERT(arguments->IsContextSlot() || arguments->IsStackAllocated()); | 1641 DCHECK(arguments->IsContextSlot() || arguments->IsStackAllocated()); |
| 1642 BuildVariableAssignment(arguments, object, Token::ASSIGN); | 1642 BuildVariableAssignment(arguments, object, Token::ASSIGN); |
| 1643 | 1643 |
| 1644 return object; | 1644 return object; |
| 1645 } | 1645 } |
| 1646 | 1646 |
| 1647 | 1647 |
| 1648 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, | 1648 Node* AstGraphBuilder::BuildHoleCheckSilent(Node* value, Node* for_hole, |
| 1649 Node* not_hole) { | 1649 Node* not_hole) { |
| 1650 IfBuilder hole_check(this); | 1650 IfBuilder hole_check(this); |
| 1651 Node* the_hole = jsgraph()->TheHoleConstant(); | 1651 Node* the_hole = jsgraph()->TheHoleConstant(); |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 UNREACHABLE(); | 1950 UNREACHABLE(); |
| 1951 js_op = NULL; | 1951 js_op = NULL; |
| 1952 } | 1952 } |
| 1953 return NewNode(js_op, left, right); | 1953 return NewNode(js_op, left, right); |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 | 1956 |
| 1957 void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) { | 1957 void AstGraphBuilder::BuildLazyBailout(Node* node, BailoutId ast_id) { |
| 1958 if (OperatorProperties::CanLazilyDeoptimize(node->op())) { | 1958 if (OperatorProperties::CanLazilyDeoptimize(node->op())) { |
| 1959 // The deopting node should have an outgoing control dependency. | 1959 // The deopting node should have an outgoing control dependency. |
| 1960 ASSERT(GetControlDependency() == node); | 1960 DCHECK(GetControlDependency() == node); |
| 1961 | 1961 |
| 1962 StructuredGraphBuilder::Environment* continuation_env = | 1962 StructuredGraphBuilder::Environment* continuation_env = |
| 1963 environment_internal(); | 1963 environment_internal(); |
| 1964 // Create environment for the deoptimization block, and build the block. | 1964 // Create environment for the deoptimization block, and build the block. |
| 1965 StructuredGraphBuilder::Environment* deopt_env = | 1965 StructuredGraphBuilder::Environment* deopt_env = |
| 1966 CopyEnvironment(continuation_env); | 1966 CopyEnvironment(continuation_env); |
| 1967 set_environment(deopt_env); | 1967 set_environment(deopt_env); |
| 1968 | 1968 |
| 1969 NewNode(common()->LazyDeoptimization()); | 1969 NewNode(common()->LazyDeoptimization()); |
| 1970 | 1970 |
| 1971 FrameStateDescriptor stateDescriptor(ast_id); | 1971 FrameStateDescriptor stateDescriptor(ast_id); |
| 1972 Node* state_node = NewNode(common()->FrameState(stateDescriptor)); | 1972 Node* state_node = NewNode(common()->FrameState(stateDescriptor)); |
| 1973 | 1973 |
| 1974 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); | 1974 Node* deoptimize_node = NewNode(common()->Deoptimize(), state_node); |
| 1975 | 1975 |
| 1976 UpdateControlDependencyToLeaveFunction(deoptimize_node); | 1976 UpdateControlDependencyToLeaveFunction(deoptimize_node); |
| 1977 | 1977 |
| 1978 // Continue with the original environment. | 1978 // Continue with the original environment. |
| 1979 set_environment(continuation_env); | 1979 set_environment(continuation_env); |
| 1980 | 1980 |
| 1981 NewNode(common()->Continuation()); | 1981 NewNode(common()->Continuation()); |
| 1982 } | 1982 } |
| 1983 } | 1983 } |
| 1984 } | 1984 } |
| 1985 } | 1985 } |
| 1986 } // namespace v8::internal::compiler | 1986 } // namespace v8::internal::compiler |
| OLD | NEW |