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/ast/compile-time-value.h" | 7 #include "src/ast/compile-time-value.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/compilation-info.h" | 9 #include "src/compilation-info.h" |
10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
(...skipping 1354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1365 expr->literal_index(), expr->properties_count()); | 1365 expr->literal_index(), expr->properties_count()); |
1366 Node* literal = NewNode(op, closure); | 1366 Node* literal = NewNode(op, closure); |
1367 PrepareFrameState(literal, expr->CreateLiteralId(), | 1367 PrepareFrameState(literal, expr->CreateLiteralId(), |
1368 OutputFrameStateCombine::Push()); | 1368 OutputFrameStateCombine::Push()); |
1369 | 1369 |
1370 // The object is expected on the operand stack during computation of the | 1370 // The object is expected on the operand stack during computation of the |
1371 // property values and is the value of the entire expression. | 1371 // property values and is the value of the entire expression. |
1372 environment()->Push(literal); | 1372 environment()->Push(literal); |
1373 | 1373 |
1374 // Create nodes to store computed values into the literal. | 1374 // Create nodes to store computed values into the literal. |
1375 int property_index = 0; | |
1376 AccessorTable accessor_table(local_zone()); | 1375 AccessorTable accessor_table(local_zone()); |
1377 for (; property_index < expr->properties()->length(); property_index++) { | 1376 for (int i = 0; i < expr->properties()->length(); i++) { |
1378 ObjectLiteral::Property* property = expr->properties()->at(property_index); | 1377 ObjectLiteral::Property* property = expr->properties()->at(i); |
1379 DCHECK(!property->is_computed_name()); | 1378 DCHECK(!property->is_computed_name()); |
1380 if (property->IsCompileTimeValue()) continue; | 1379 if (property->IsCompileTimeValue()) continue; |
1381 | 1380 |
1382 Literal* key = property->key()->AsLiteral(); | 1381 Literal* key = property->key()->AsLiteral(); |
1383 switch (property->kind()) { | 1382 switch (property->kind()) { |
1384 case ObjectLiteral::Property::CONSTANT: | 1383 case ObjectLiteral::Property::CONSTANT: |
1385 UNREACHABLE(); | 1384 UNREACHABLE(); |
1386 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1385 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1387 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); | 1386 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); |
1388 // Fall through. | 1387 // Fall through. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1426 case ObjectLiteral::Property::PROTOTYPE: { | 1425 case ObjectLiteral::Property::PROTOTYPE: { |
1427 environment()->Push(environment()->Top()); // Duplicate receiver. | 1426 environment()->Push(environment()->Top()); // Duplicate receiver. |
1428 VisitForValue(property->value()); | 1427 VisitForValue(property->value()); |
1429 Node* value = environment()->Pop(); | 1428 Node* value = environment()->Pop(); |
1430 Node* receiver = environment()->Pop(); | 1429 Node* receiver = environment()->Pop(); |
1431 DCHECK(property->emit_store()); | 1430 DCHECK(property->emit_store()); |
1432 const Operator* op = | 1431 const Operator* op = |
1433 javascript()->CallRuntime(Runtime::kInternalSetPrototype); | 1432 javascript()->CallRuntime(Runtime::kInternalSetPrototype); |
1434 Node* set_prototype = NewNode(op, receiver, value); | 1433 Node* set_prototype = NewNode(op, receiver, value); |
1435 // SetPrototype should not lazy deopt on an object literal. | 1434 // SetPrototype should not lazy deopt on an object literal. |
1436 PrepareFrameState(set_prototype, | 1435 PrepareFrameState(set_prototype, expr->GetIdForPropertySet(i)); |
1437 expr->GetIdForPropertySet(property_index)); | |
1438 break; | 1436 break; |
1439 } | 1437 } |
1440 case ObjectLiteral::Property::GETTER: | 1438 case ObjectLiteral::Property::GETTER: |
1441 if (property->emit_store()) { | 1439 if (property->emit_store()) { |
1442 AccessorTable::Iterator it = accessor_table.lookup(key); | 1440 AccessorTable::Iterator it = accessor_table.lookup(key); |
1443 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1441 it->second->bailout_id = expr->GetIdForPropertySet(i); |
1444 it->second->getter = property; | 1442 it->second->getter = property; |
1445 } | 1443 } |
1446 break; | 1444 break; |
1447 case ObjectLiteral::Property::SETTER: | 1445 case ObjectLiteral::Property::SETTER: |
1448 if (property->emit_store()) { | 1446 if (property->emit_store()) { |
1449 AccessorTable::Iterator it = accessor_table.lookup(key); | 1447 AccessorTable::Iterator it = accessor_table.lookup(key); |
1450 it->second->bailout_id = expr->GetIdForPropertySet(property_index); | 1448 it->second->bailout_id = expr->GetIdForPropertySet(i); |
1451 it->second->setter = property; | 1449 it->second->setter = property; |
1452 } | 1450 } |
1453 break; | 1451 break; |
1454 } | 1452 } |
1455 } | 1453 } |
1456 | 1454 |
1457 // Create nodes to define accessors, using only a single call to the runtime | 1455 // Create nodes to define accessors, using only a single call to the runtime |
1458 // for each pair of corresponding getters and setters. | 1456 // for each pair of corresponding getters and setters. |
1459 literal = environment()->Top(); // Reload from operand stack. | 1457 literal = environment()->Top(); // Reload from operand stack. |
1460 for (AccessorTable::Iterator it = accessor_table.begin(); | 1458 for (AccessorTable::Iterator it = accessor_table.begin(); |
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3527 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, | 3525 float invocation_frequency, LoopAssignmentAnalysis* loop_assignment, |
3528 SourcePositionTable* source_positions, int inlining_id) | 3526 SourcePositionTable* source_positions, int inlining_id) |
3529 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, | 3527 : AstGraphBuilder(local_zone, info, jsgraph, invocation_frequency, |
3530 loop_assignment), | 3528 loop_assignment), |
3531 source_positions_(source_positions), | 3529 source_positions_(source_positions), |
3532 start_position_(info->shared_info()->start_position(), inlining_id) {} | 3530 start_position_(info->shared_info()->start_position(), inlining_id) {} |
3533 | 3531 |
3534 } // namespace compiler | 3532 } // namespace compiler |
3535 } // namespace internal | 3533 } // namespace internal |
3536 } // namespace v8 | 3534 } // namespace v8 |
OLD | NEW |