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

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

Issue 1410953003: [Interpreter] Adds delete operator to interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/compiler.h" 9 #include "src/compiler.h"
10 #include "src/interpreter/control-flow-builders.h" 10 #include "src/interpreter/control-flow-builders.h"
(...skipping 1128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1139 switch (expr->op()) { 1139 switch (expr->op()) {
1140 case Token::Value::NOT: 1140 case Token::Value::NOT:
1141 VisitNot(expr); 1141 VisitNot(expr);
1142 break; 1142 break;
1143 case Token::Value::TYPEOF: 1143 case Token::Value::TYPEOF:
1144 VisitTypeOf(expr); 1144 VisitTypeOf(expr);
1145 break; 1145 break;
1146 case Token::Value::VOID: 1146 case Token::Value::VOID:
1147 VisitVoid(expr); 1147 VisitVoid(expr);
1148 break; 1148 break;
1149 case Token::Value::DELETE:
1150 VisitDeleteOperation(expr);
1151 break;
1152 // These operators are converted to an equivalent binary operators in
1153 // the parser. These operators are not expected to be visited here.
1149 case Token::Value::BIT_NOT: 1154 case Token::Value::BIT_NOT:
1150 case Token::Value::DELETE: 1155 case Token::Value::ADD:
1156 case Token::Value::SUB:
1151 UNIMPLEMENTED(); 1157 UNIMPLEMENTED();
rmcilroy 2015/10/21 14:52:54 These should be UNREACHABLE instead of UNIMPLEMENT
1152 default: 1158 default:
1153 UNREACHABLE(); 1159 UNREACHABLE();
1154 } 1160 }
1155 } 1161 }
1156 1162
1157 1163
1164 void BytecodeGenerator::VisitDeleteOperation(UnaryOperation* expr) {
rmcilroy 2015/10/21 14:52:54 nit - drop Operator (just VisitDelete)
mythria 2015/10/23 14:48:01 Done.
1165 if (expr->expression()->IsProperty()) {
1166 Property* property = expr->expression()->AsProperty();
1167 TemporaryRegisterScope temporary_register_scope(builder());
1168 Register temporary = temporary_register_scope.NewRegister();
rmcilroy 2015/10/21 14:52:54 call this object (no need to store property->obj()
mythria 2015/10/23 14:48:01 Done.
1169 Expression* obj = property->obj();
1170 Visit(obj);
1171 builder()->StoreAccumulatorInRegister(temporary);
1172 Expression* key = property->key();
1173 Visit(key);
1174 builder()->Delete(temporary, language_mode());
1175 } else if (expr->expression()->IsVariableProxy()) {
1176 VariableProxy* proxy_expr = expr->expression()->AsVariableProxy();
1177 VisitVariableDelete(proxy_expr);
rmcilroy 2015/10/21 14:52:54 nit - I would just inline this since it isn't call
mythria 2015/10/23 14:48:00 Done.
1178 } else {
1179 Visit(expr->expression());
rmcilroy 2015/10/21 14:52:54 Comments please (throughout this whole function an
mythria 2015/10/23 14:48:00 Done.
1180 builder()->LoadTrue();
1181 }
1182 }
1183
1184
1185 void BytecodeGenerator::VisitVariableDelete(VariableProxy* proxy) {
1186 Variable* variable = proxy->var();
1187 DCHECK(is_sloppy(language_mode()) || variable->HasThisName(isolate()));
1188 switch (variable->location()) {
1189 case VariableLocation::GLOBAL:
1190 case VariableLocation::UNALLOCATED: {
1191 TemporaryRegisterScope temporary_register_scope(builder());
1192 Register temporary = temporary_register_scope.NewRegister();
rmcilroy 2015/10/21 14:52:54 nit - call this global_object
mythria 2015/10/23 14:48:00 Done.
1193 builder()->LoadContextSlot(execution_context()->reg(),
1194 Context::GLOBAL_OBJECT_INDEX);
1195 builder()->StoreAccumulatorInRegister(temporary);
1196 builder()->LoadLiteral(variable->name());
1197 builder()->Delete(temporary, language_mode());
rmcilroy 2015/10/21 14:52:54 nit - chain the builder calls - i.e.: builder()
mythria 2015/10/23 14:48:00 Done.
1198 }
1199 return;
rmcilroy 2015/10/21 14:52:54 break, not return, and put it inside the "{ .. }"
mythria 2015/10/23 14:48:00 Done.
1200 case VariableLocation::PARAMETER:
1201 case VariableLocation::LOCAL:
1202 case VariableLocation::CONTEXT: {
1203 if (variable->HasThisName(isolate())) {
rmcilroy 2015/10/21 14:52:54 comments
mythria 2015/10/23 14:48:00 Done.
1204 builder()->LoadTrue();
1205 } else {
1206 builder()->LoadFalse();
1207 }
1208 }
1209 return;
rmcilroy 2015/10/21 14:52:54 ditto
mythria 2015/10/23 14:48:00 Done.
1210 case VariableLocation::LOOKUP: {
1211 UNIMPLEMENTED();
rmcilroy 2015/10/21 14:52:54 break;
mythria 2015/10/23 14:48:00 Done.
1212 }
1213 UNREACHABLE();
rmcilroy 2015/10/21 14:52:54 Remove this (if you don't have "default" then it i
mythria 2015/10/23 14:48:00 Done.
1214 }
1215 }
1216
1217
1158 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) { 1218 void BytecodeGenerator::VisitCountOperation(CountOperation* expr) {
1159 UNIMPLEMENTED(); 1219 UNIMPLEMENTED();
1160 } 1220 }
1161 1221
1162 1222
1163 void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) { 1223 void BytecodeGenerator::VisitBinaryOperation(BinaryOperation* binop) {
1164 switch (binop->op()) { 1224 switch (binop->op()) {
1165 case Token::COMMA: 1225 case Token::COMMA:
1166 VisitCommaExpression(binop); 1226 VisitCommaExpression(binop);
1167 break; 1227 break;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 } 1481 }
1422 1482
1423 1483
1424 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { 1484 int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
1425 return info()->feedback_vector()->GetIndex(slot); 1485 return info()->feedback_vector()->GetIndex(slot);
1426 } 1486 }
1427 1487
1428 } // namespace interpreter 1488 } // namespace interpreter
1429 } // namespace internal 1489 } // namespace internal
1430 } // namespace v8 1490 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698