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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 1588903002: [Interpreter] Fixes VisitObjectLiteral to reserve consecutive registers in innerscope. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-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/control-flow-builders.h" 9 #include "src/interpreter/control-flow-builders.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 } 922 }
923 923
924 924
925 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { 925 void BytecodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
926 // Deep-copy the literal boilerplate. 926 // Deep-copy the literal boilerplate.
927 builder()->CreateObjectLiteral(expr->constant_properties(), 927 builder()->CreateObjectLiteral(expr->constant_properties(),
928 expr->literal_index(), 928 expr->literal_index(),
929 expr->ComputeFlags(true)); 929 expr->ComputeFlags(true));
930 930
931 TemporaryRegisterScope temporary_register_scope(builder()); 931 TemporaryRegisterScope temporary_register_scope(builder());
932 Register literal; 932 Register literal;
rmcilroy 2016/01/14 14:04:23 As discussed offline, let's just always put litera
mythria 2016/01/15 16:48:24 Done.
933 933
934 // Store computed values into the literal. 934 // Store computed values into the literal.
935 bool literal_in_accumulator = true; 935 bool literal_in_accumulator = true;
936 int property_index = 0; 936 int property_index = 0;
937 AccessorTable accessor_table(zone()); 937 AccessorTable accessor_table(zone());
938 for (; property_index < expr->properties()->length(); property_index++) { 938 for (; property_index < expr->properties()->length(); property_index++) {
939 TemporaryRegisterScope inner_temporary_register_scope(builder()); 939 TemporaryRegisterScope inner_temporary_register_scope(builder());
940 ObjectLiteral::Property* property = expr->properties()->at(property_index); 940 ObjectLiteral::Property* property = expr->properties()->at(property_index);
941 if (property->is_computed_name()) break; 941 if (property->is_computed_name()) break;
942 if (property->IsCompileTimeValue()) continue; 942 if (property->IsCompileTimeValue()) continue;
943 943
944 if (literal_in_accumulator) { 944 if (literal_in_accumulator) {
945 literal = temporary_register_scope.NewRegister(); 945 // We reserve for 5 though we use only one in this scope. This register
946 // is used as a parameter along with other registers allocated in the
947 // inner scope. Since they have to be contiguous, reserving 5 registers
948 // lets inner scope allocate consecutive registers starting with this
949 // register.
950 temporary_register_scope.PrepareForConsecutiveAllocations(5);
mythria 2016/01/14 10:08:55 This increases the number of registers used. So al
951 literal = temporary_register_scope.NextConsecutiveRegister();
946 builder()->StoreAccumulatorInRegister(literal); 952 builder()->StoreAccumulatorInRegister(literal);
947 literal_in_accumulator = false; 953 literal_in_accumulator = false;
948 } 954 }
949 955
950 Literal* literal_key = property->key()->AsLiteral(); 956 Literal* literal_key = property->key()->AsLiteral();
951 switch (property->kind()) { 957 switch (property->kind()) {
952 case ObjectLiteral::Property::CONSTANT: 958 case ObjectLiteral::Property::CONSTANT:
953 UNREACHABLE(); 959 UNREACHABLE();
954 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 960 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
955 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value())); 961 DCHECK(!CompileTimeValue::IsCompileTimeValue(property->value()));
(...skipping 13 matching lines...) Expand all
969 } else { 975 } else {
970 inner_temporary_register_scope.PrepareForConsecutiveAllocations(3); 976 inner_temporary_register_scope.PrepareForConsecutiveAllocations(3);
971 Register key = 977 Register key =
972 inner_temporary_register_scope.NextConsecutiveRegister(); 978 inner_temporary_register_scope.NextConsecutiveRegister();
973 Register value = 979 Register value =
974 inner_temporary_register_scope.NextConsecutiveRegister(); 980 inner_temporary_register_scope.NextConsecutiveRegister();
975 Register language = 981 Register language =
976 inner_temporary_register_scope.NextConsecutiveRegister(); 982 inner_temporary_register_scope.NextConsecutiveRegister();
977 // TODO(oth): This is problematic - can't assume contiguous here. 983 // TODO(oth): This is problematic - can't assume contiguous here.
978 // literal is allocated in temporary_register_scope, whereas 984 // literal is allocated in temporary_register_scope, whereas
979 // key, value, language are in another. 985 // key, value, language are in another.
rmcilroy 2016/01/14 14:04:23 Remove this TODO
mythria 2016/01/15 16:48:24 Done.
980 DCHECK(Register::AreContiguous(literal, key, value, language)); 986 DCHECK(Register::AreContiguous(literal, key, value, language));
981 VisitForAccumulatorValue(property->key()); 987 VisitForAccumulatorValue(property->key());
982 builder()->StoreAccumulatorInRegister(key); 988 builder()->StoreAccumulatorInRegister(key);
983 VisitForAccumulatorValue(property->value()); 989 VisitForAccumulatorValue(property->value());
984 builder()->StoreAccumulatorInRegister(value); 990 builder()->StoreAccumulatorInRegister(value);
985 if (property->emit_store()) { 991 if (property->emit_store()) {
986 builder() 992 builder()
987 ->LoadLiteral(Smi::FromInt(SLOPPY)) 993 ->LoadLiteral(Smi::FromInt(SLOPPY))
988 .StoreAccumulatorInRegister(language) 994 .StoreAccumulatorInRegister(language)
989 .CallRuntime(Runtime::kSetProperty, literal, 4); 995 .CallRuntime(Runtime::kSetProperty, literal, 4);
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
2149 } 2155 }
2150 2156
2151 2157
2152 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 2158 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
2153 return info()->feedback_vector()->GetIndex(slot); 2159 return info()->feedback_vector()->GetIndex(slot);
2154 } 2160 }
2155 2161
2156 } // namespace interpreter 2162 } // namespace interpreter
2157 } // namespace internal 2163 } // namespace internal
2158 } // namespace v8 2164 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698