OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/bytecode-generator.h" | 5 #include "src/interpreter/bytecode-generator.h" |
6 | 6 |
7 #include "src/ast/scopes.h" | 7 #include "src/ast/scopes.h" |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/interpreter/bytecode-register-allocator.h" | 9 #include "src/interpreter/bytecode-register-allocator.h" |
10 #include "src/interpreter/control-flow-builders.h" | 10 #include "src/interpreter/control-flow-builders.h" |
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 register_allocator()->NextConsecutiveRegister(); | 1412 register_allocator()->NextConsecutiveRegister(); |
1413 Register value = register_allocator()->NextConsecutiveRegister(); | 1413 Register value = register_allocator()->NextConsecutiveRegister(); |
1414 | 1414 |
1415 builder()->MoveRegister(literal, literal_argument); | 1415 builder()->MoveRegister(literal, literal_argument); |
1416 VisitForAccumulatorValue(property->value()); | 1416 VisitForAccumulatorValue(property->value()); |
1417 builder()->StoreAccumulatorInRegister(value).CallRuntime( | 1417 builder()->StoreAccumulatorInRegister(value).CallRuntime( |
1418 Runtime::kInternalSetPrototype, literal_argument, 2); | 1418 Runtime::kInternalSetPrototype, literal_argument, 2); |
1419 continue; | 1419 continue; |
1420 } | 1420 } |
1421 | 1421 |
1422 register_allocator()->PrepareForConsecutiveAllocations(4); | 1422 register_allocator()->PrepareForConsecutiveAllocations(5); |
1423 Register literal_argument = register_allocator()->NextConsecutiveRegister(); | 1423 Register literal_argument = register_allocator()->NextConsecutiveRegister(); |
1424 Register key = register_allocator()->NextConsecutiveRegister(); | 1424 Register key = register_allocator()->NextConsecutiveRegister(); |
1425 Register value = register_allocator()->NextConsecutiveRegister(); | 1425 Register value = register_allocator()->NextConsecutiveRegister(); |
1426 Register attr = register_allocator()->NextConsecutiveRegister(); | 1426 Register attr = register_allocator()->NextConsecutiveRegister(); |
1427 DCHECK(Register::AreContiguous(literal_argument, key, value, attr)); | 1427 DCHECK(Register::AreContiguous(literal_argument, key, value, attr)); |
| 1428 Register set_function_name = |
| 1429 register_allocator()->NextConsecutiveRegister(); |
1428 | 1430 |
1429 builder()->MoveRegister(literal, literal_argument); | 1431 builder()->MoveRegister(literal, literal_argument); |
1430 VisitForAccumulatorValue(property->key()); | 1432 VisitForAccumulatorValue(property->key()); |
1431 builder()->CastAccumulatorToName().StoreAccumulatorInRegister(key); | 1433 builder()->CastAccumulatorToName().StoreAccumulatorInRegister(key); |
1432 VisitForAccumulatorValue(property->value()); | 1434 VisitForAccumulatorValue(property->value()); |
1433 builder()->StoreAccumulatorInRegister(value); | 1435 builder()->StoreAccumulatorInRegister(value); |
1434 VisitSetHomeObject(value, literal, property); | 1436 VisitSetHomeObject(value, literal, property); |
1435 builder()->LoadLiteral(Smi::FromInt(NONE)).StoreAccumulatorInRegister(attr); | 1437 builder()->LoadLiteral(Smi::FromInt(NONE)).StoreAccumulatorInRegister(attr); |
1436 Runtime::FunctionId function_id = static_cast<Runtime::FunctionId>(-1); | |
1437 switch (property->kind()) { | 1438 switch (property->kind()) { |
1438 case ObjectLiteral::Property::CONSTANT: | 1439 case ObjectLiteral::Property::CONSTANT: |
1439 case ObjectLiteral::Property::COMPUTED: | 1440 case ObjectLiteral::Property::COMPUTED: |
1440 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1441 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
1441 function_id = Runtime::kDefineDataPropertyUnchecked; | 1442 builder() |
| 1443 ->LoadLiteral(Smi::FromInt(property->NeedsSetFunctionName())) |
| 1444 .StoreAccumulatorInRegister(set_function_name); |
| 1445 builder()->CallRuntime(Runtime::kDefineDataPropertyInLiteral, |
| 1446 literal_argument, 5); |
1442 break; | 1447 break; |
1443 case ObjectLiteral::Property::PROTOTYPE: | 1448 case ObjectLiteral::Property::PROTOTYPE: |
1444 UNREACHABLE(); // Handled specially above. | 1449 UNREACHABLE(); // Handled specially above. |
1445 break; | 1450 break; |
1446 case ObjectLiteral::Property::GETTER: | 1451 case ObjectLiteral::Property::GETTER: |
1447 function_id = Runtime::kDefineGetterPropertyUnchecked; | 1452 builder()->CallRuntime(Runtime::kDefineGetterPropertyUnchecked, |
| 1453 literal_argument, 4); |
1448 break; | 1454 break; |
1449 case ObjectLiteral::Property::SETTER: | 1455 case ObjectLiteral::Property::SETTER: |
1450 function_id = Runtime::kDefineSetterPropertyUnchecked; | 1456 builder()->CallRuntime(Runtime::kDefineSetterPropertyUnchecked, |
| 1457 literal_argument, 4); |
1451 break; | 1458 break; |
1452 } | 1459 } |
1453 builder()->CallRuntime(function_id, literal_argument, 4); | |
1454 } | 1460 } |
1455 | 1461 |
1456 // Transform literals that contain functions to fast properties. | 1462 // Transform literals that contain functions to fast properties. |
1457 if (expr->has_function()) { | 1463 if (expr->has_function()) { |
1458 builder()->CallRuntime(Runtime::kToFastProperties, literal, 1); | 1464 builder()->CallRuntime(Runtime::kToFastProperties, literal, 1); |
1459 } | 1465 } |
1460 | 1466 |
1461 execution_result()->SetResultInRegister(literal); | 1467 execution_result()->SetResultInRegister(literal); |
1462 } | 1468 } |
1463 | 1469 |
(...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2507 } | 2513 } |
2508 | 2514 |
2509 | 2515 |
2510 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { | 2516 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { |
2511 return info()->feedback_vector()->GetIndex(slot); | 2517 return info()->feedback_vector()->GetIndex(slot); |
2512 } | 2518 } |
2513 | 2519 |
2514 } // namespace interpreter | 2520 } // namespace interpreter |
2515 } // namespace internal | 2521 } // namespace internal |
2516 } // namespace v8 | 2522 } // namespace v8 |
OLD | NEW |