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/ast-loop-assignment-analyzer.h" | 8 #include "src/compiler/ast-loop-assignment-analyzer.h" |
9 #include "src/compiler/control-builders.h" | 9 #include "src/compiler/control-builders.h" |
10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
(...skipping 1384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1395 environment()->Push(proto); | 1395 environment()->Push(proto); |
1396 | 1396 |
1397 // Create nodes to store method values into the literal. | 1397 // Create nodes to store method values into the literal. |
1398 for (int i = 0; i < expr->properties()->length(); i++) { | 1398 for (int i = 0; i < expr->properties()->length(); i++) { |
1399 ObjectLiteral::Property* property = expr->properties()->at(i); | 1399 ObjectLiteral::Property* property = expr->properties()->at(i); |
1400 environment()->Push(property->is_static() ? literal : proto); | 1400 environment()->Push(property->is_static() ? literal : proto); |
1401 | 1401 |
1402 VisitForValue(property->key()); | 1402 VisitForValue(property->key()); |
1403 environment()->Push( | 1403 environment()->Push( |
1404 BuildToName(environment()->Pop(), expr->GetIdForProperty(i))); | 1404 BuildToName(environment()->Pop(), expr->GetIdForProperty(i))); |
| 1405 |
| 1406 // The static prototype property is read only. We handle the non computed |
| 1407 // property name case in the parser. Since this is the only case where we |
| 1408 // need to check for an own read only property we special case this so we do |
| 1409 // not need to do this for every property. |
| 1410 if (property->is_static() && property->is_computed_name()) { |
| 1411 Node* name = environment()->Pop(); |
| 1412 environment()->Push( |
| 1413 BuildThrowIfStaticPrototype(name, expr->GetIdForProperty(i))); |
| 1414 } |
| 1415 |
1405 VisitForValue(property->value()); | 1416 VisitForValue(property->value()); |
1406 Node* value = environment()->Pop(); | 1417 Node* value = environment()->Pop(); |
1407 Node* key = environment()->Pop(); | 1418 Node* key = environment()->Pop(); |
1408 Node* receiver = environment()->Pop(); | 1419 Node* receiver = environment()->Pop(); |
1409 BuildSetHomeObject(value, receiver, property->value()); | 1420 BuildSetHomeObject(value, receiver, property->value()); |
1410 | 1421 |
1411 switch (property->kind()) { | 1422 switch (property->kind()) { |
1412 case ObjectLiteral::Property::CONSTANT: | 1423 case ObjectLiteral::Property::CONSTANT: |
1413 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1424 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1414 case ObjectLiteral::Property::PROTOTYPE: | 1425 case ObjectLiteral::Property::PROTOTYPE: |
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 hole_check.If(check); | 2586 hole_check.If(check); |
2576 hole_check.Then(); | 2587 hole_check.Then(); |
2577 environment()->Push(BuildThrowReferenceError(variable, bailout_id)); | 2588 environment()->Push(BuildThrowReferenceError(variable, bailout_id)); |
2578 hole_check.Else(); | 2589 hole_check.Else(); |
2579 environment()->Push(not_hole); | 2590 environment()->Push(not_hole); |
2580 hole_check.End(); | 2591 hole_check.End(); |
2581 return environment()->Pop(); | 2592 return environment()->Pop(); |
2582 } | 2593 } |
2583 | 2594 |
2584 | 2595 |
| 2596 Node* AstGraphBuilder::BuildThrowIfStaticPrototype(Node* name, |
| 2597 BailoutId bailout_id) { |
| 2598 IfBuilder prototype_check(this); |
| 2599 Node* prototype_string = |
| 2600 jsgraph()->Constant(isolate()->factory()->prototype_string()); |
| 2601 Node* check = NewNode(javascript()->StrictEqual(), name, prototype_string); |
| 2602 prototype_check.If(check); |
| 2603 prototype_check.Then(); |
| 2604 { |
| 2605 const Operator* op = |
| 2606 javascript()->CallRuntime(Runtime::kThrowStaticPrototypeError, 0); |
| 2607 Node* call = NewNode(op); |
| 2608 PrepareFrameState(call, bailout_id); |
| 2609 environment()->Push(call); |
| 2610 } |
| 2611 prototype_check.Else(); |
| 2612 environment()->Push(name); |
| 2613 prototype_check.End(); |
| 2614 return environment()->Pop(); |
| 2615 } |
| 2616 |
| 2617 |
2585 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, | 2618 Node* AstGraphBuilder::BuildVariableLoad(Variable* variable, |
2586 BailoutId bailout_id, | 2619 BailoutId bailout_id, |
2587 const VectorSlotPair& feedback, | 2620 const VectorSlotPair& feedback, |
2588 ContextualMode contextual_mode) { | 2621 ContextualMode contextual_mode) { |
2589 Node* the_hole = jsgraph()->TheHoleConstant(); | 2622 Node* the_hole = jsgraph()->TheHoleConstant(); |
2590 VariableMode mode = variable->mode(); | 2623 VariableMode mode = variable->mode(); |
2591 switch (variable->location()) { | 2624 switch (variable->location()) { |
2592 case Variable::UNALLOCATED: { | 2625 case Variable::UNALLOCATED: { |
2593 // Global var, const, or let variable. | 2626 // Global var, const, or let variable. |
2594 Node* global = BuildLoadGlobalObject(); | 2627 Node* global = BuildLoadGlobalObject(); |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3300 // Phi does not exist yet, introduce one. | 3333 // Phi does not exist yet, introduce one. |
3301 value = NewPhi(inputs, value, control); | 3334 value = NewPhi(inputs, value, control); |
3302 value->ReplaceInput(inputs - 1, other); | 3335 value->ReplaceInput(inputs - 1, other); |
3303 } | 3336 } |
3304 return value; | 3337 return value; |
3305 } | 3338 } |
3306 | 3339 |
3307 } // namespace compiler | 3340 } // namespace compiler |
3308 } // namespace internal | 3341 } // namespace internal |
3309 } // namespace v8 | 3342 } // namespace v8 |
OLD | NEW |