Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/interpreter/bytecode-array-builder.cc

Issue 1410953003: [Interpreter] Adds delete operator to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Added more tests for delete and addressed review comments Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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-array-builder.h" 5 #include "src/interpreter/bytecode-array-builder.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace interpreter { 9 namespace interpreter {
10 10
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( 689 BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
690 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) { 690 Runtime::FunctionId function_id, Register first_arg, size_t arg_count) {
691 DCHECK(FitsInIdx16Operand(function_id)); 691 DCHECK(FitsInIdx16Operand(function_id));
692 DCHECK(FitsInIdx8Operand(arg_count)); 692 DCHECK(FitsInIdx8Operand(arg_count));
693 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id), 693 Output(Bytecode::kCallRuntime, static_cast<uint16_t>(function_id),
694 first_arg.ToOperand(), static_cast<uint8_t>(arg_count)); 694 first_arg.ToOperand(), static_cast<uint8_t>(arg_count));
695 return *this; 695 return *this;
696 } 696 }
697 697
698 698
699 BytecodeArrayBuilder& BytecodeArrayBuilder::Delete(Register object,
700 LanguageMode language_mode) {
701 Output(BytecodeForDelete(language_mode), object.ToOperand());
702 return *this;
703 }
704
705
699 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) { 706 size_t BytecodeArrayBuilder::GetConstantPoolEntry(Handle<Object> object) {
700 // These constants shouldn't be added to the constant pool, the should use 707 // These constants shouldn't be added to the constant pool, the should use
701 // specialzed bytecodes instead. 708 // specialzed bytecodes instead.
702 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value())); 709 DCHECK(!object.is_identical_to(isolate_->factory()->undefined_value()));
703 DCHECK(!object.is_identical_to(isolate_->factory()->null_value())); 710 DCHECK(!object.is_identical_to(isolate_->factory()->null_value()));
704 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value())); 711 DCHECK(!object.is_identical_to(isolate_->factory()->the_hole_value()));
705 DCHECK(!object.is_identical_to(isolate_->factory()->true_value())); 712 DCHECK(!object.is_identical_to(isolate_->factory()->true_value()));
706 DCHECK(!object.is_identical_to(isolate_->factory()->false_value())); 713 DCHECK(!object.is_identical_to(isolate_->factory()->false_value()));
707 714
708 size_t* entry = constants_map_.Find(object); 715 size_t* entry = constants_map_.Find(object);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 case CreateArgumentsType::kUnmappedArguments: 1016 case CreateArgumentsType::kUnmappedArguments:
1010 return Bytecode::kCreateUnmappedArguments; 1017 return Bytecode::kCreateUnmappedArguments;
1011 default: 1018 default:
1012 UNREACHABLE(); 1019 UNREACHABLE();
1013 } 1020 }
1014 return static_cast<Bytecode>(-1); 1021 return static_cast<Bytecode>(-1);
1015 } 1022 }
1016 1023
1017 1024
1018 // static 1025 // static
1026 Bytecode BytecodeArrayBuilder::BytecodeForDelete(
1027 LanguageMode language_mode) {
1028 switch (language_mode) {
1029 case SLOPPY:
1030 return Bytecode::kDeletePropertySloppy;
1031 case STRICT:
1032 return Bytecode::kDeletePropertyStrict;
1033 case STRONG:
1034 UNIMPLEMENTED();
1035 default:
1036 UNREACHABLE();
1037 }
1038 return static_cast<Bytecode>(-1);
1039 }
1040
1041
1042 // static
1019 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { 1043 bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) {
1020 return kMinUInt8 <= value && value <= kMaxUInt8; 1044 return kMinUInt8 <= value && value <= kMaxUInt8;
1021 } 1045 }
1022 1046
1023 1047
1024 // static 1048 // static
1025 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) { 1049 bool BytecodeArrayBuilder::FitsInIdx8Operand(size_t value) {
1026 return value <= static_cast<size_t>(kMaxUInt8); 1050 return value <= static_cast<size_t>(kMaxUInt8);
1027 } 1051 }
1028 1052
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 DCHECK_GT(next_consecutive_count_, 0); 1099 DCHECK_GT(next_consecutive_count_, 0);
1076 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_); 1100 builder_->BorrowConsecutiveTemporaryRegister(next_consecutive_register_);
1077 allocated_.push_back(next_consecutive_register_); 1101 allocated_.push_back(next_consecutive_register_);
1078 next_consecutive_count_--; 1102 next_consecutive_count_--;
1079 return Register(next_consecutive_register_++); 1103 return Register(next_consecutive_register_++);
1080 } 1104 }
1081 1105
1082 } // namespace interpreter 1106 } // namespace interpreter
1083 } // namespace internal 1107 } // namespace internal
1084 } // namespace v8 1108 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698