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

Side by Side Diff: src/full-codegen/arm/full-codegen-arm.cc

Issue 2547433003: [fullcodegen] Remove non-"static" part in VisitArrayLiteral functions. (Closed)
Patch Set: Simplify bailout id in ObjectLiteral. Created 4 years 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 | « src/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 #if V8_TARGET_ARCH_ARM 5 #if V8_TARGET_ARCH_ARM
6 6
7 #include "src/full-codegen/full-codegen.h" 7 #include "src/full-codegen/full-codegen.h"
8 #include "src/ast/compile-time-value.h" 8 #include "src/ast/compile-time-value.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1207 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 __ CallStub(&stub); 1218 __ CallStub(&stub);
1219 RestoreContext(); 1219 RestoreContext();
1220 } 1220 }
1221 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); 1221 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER);
1222 1222
1223 // If result_saved is true the result is on top of the stack. If 1223 // If result_saved is true the result is on top of the stack. If
1224 // result_saved is false the result is in r0. 1224 // result_saved is false the result is in r0.
1225 bool result_saved = false; 1225 bool result_saved = false;
1226 1226
1227 AccessorTable accessor_table(zone()); 1227 AccessorTable accessor_table(zone());
1228 int property_index = 0; 1228 for (int i = 0; i < expr->properties()->length(); i++) {
1229 for (; property_index < expr->properties()->length(); property_index++) { 1229 ObjectLiteral::Property* property = expr->properties()->at(i);
1230 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1230 DCHECK(!property->is_computed_name());
1231 if (property->is_computed_name()) break;
1232 if (property->IsCompileTimeValue()) continue; 1231 if (property->IsCompileTimeValue()) continue;
1233 1232
1234 Literal* key = property->key()->AsLiteral(); 1233 Literal* key = property->key()->AsLiteral();
1235 Expression* value = property->value(); 1234 Expression* value = property->value();
1236 if (!result_saved) { 1235 if (!result_saved) {
1237 PushOperand(r0); // Save result on stack 1236 PushOperand(r0); // Save result on stack
1238 result_saved = true; 1237 result_saved = true;
1239 } 1238 }
1240 switch (property->kind()) { 1239 switch (property->kind()) {
1241 case ObjectLiteral::Property::CONSTANT: 1240 case ObjectLiteral::Property::CONSTANT:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1279 DropOperands(3); 1278 DropOperands(3);
1280 } 1279 }
1281 break; 1280 break;
1282 case ObjectLiteral::Property::PROTOTYPE: 1281 case ObjectLiteral::Property::PROTOTYPE:
1283 // Duplicate receiver on stack. 1282 // Duplicate receiver on stack.
1284 __ ldr(r0, MemOperand(sp)); 1283 __ ldr(r0, MemOperand(sp));
1285 PushOperand(r0); 1284 PushOperand(r0);
1286 VisitForStackValue(value); 1285 VisitForStackValue(value);
1287 DCHECK(property->emit_store()); 1286 DCHECK(property->emit_store());
1288 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); 1287 CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
1289 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), 1288 PrepareForBailoutForId(expr->GetIdForPropertySet(i),
1290 BailoutState::NO_REGISTERS); 1289 BailoutState::NO_REGISTERS);
1291 break; 1290 break;
1292 1291
1293 case ObjectLiteral::Property::GETTER: 1292 case ObjectLiteral::Property::GETTER:
1294 if (property->emit_store()) { 1293 if (property->emit_store()) {
1295 AccessorTable::Iterator it = accessor_table.lookup(key); 1294 AccessorTable::Iterator it = accessor_table.lookup(key);
1296 it->second->bailout_id = expr->GetIdForPropertySet(property_index); 1295 it->second->bailout_id = expr->GetIdForPropertySet(i);
1297 it->second->getter = property; 1296 it->second->getter = property;
1298 } 1297 }
1299 break; 1298 break;
1300 case ObjectLiteral::Property::SETTER: 1299 case ObjectLiteral::Property::SETTER:
1301 if (property->emit_store()) { 1300 if (property->emit_store()) {
1302 AccessorTable::Iterator it = accessor_table.lookup(key); 1301 AccessorTable::Iterator it = accessor_table.lookup(key);
1303 it->second->bailout_id = expr->GetIdForPropertySet(property_index); 1302 it->second->bailout_id = expr->GetIdForPropertySet(i);
1304 it->second->setter = property; 1303 it->second->setter = property;
1305 } 1304 }
1306 break; 1305 break;
1307 } 1306 }
1308 } 1307 }
1309 1308
1310 // Emit code to define accessors, using only a single call to the runtime for 1309 // Emit code to define accessors, using only a single call to the runtime for
1311 // each pair of corresponding getters and setters. 1310 // each pair of corresponding getters and setters.
1312 for (AccessorTable::Iterator it = accessor_table.begin(); 1311 for (AccessorTable::Iterator it = accessor_table.begin();
1313 it != accessor_table.end(); 1312 it != accessor_table.end();
1314 ++it) { 1313 ++it) {
1315 __ ldr(r0, MemOperand(sp)); // Duplicate receiver. 1314 __ ldr(r0, MemOperand(sp)); // Duplicate receiver.
1316 PushOperand(r0); 1315 PushOperand(r0);
1317 VisitForStackValue(it->first); 1316 VisitForStackValue(it->first);
1318 EmitAccessor(it->second->getter); 1317 EmitAccessor(it->second->getter);
1319 EmitAccessor(it->second->setter); 1318 EmitAccessor(it->second->setter);
1320 __ mov(r0, Operand(Smi::FromInt(NONE))); 1319 __ mov(r0, Operand(Smi::FromInt(NONE)));
1321 PushOperand(r0); 1320 PushOperand(r0);
1322 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); 1321 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked);
1323 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); 1322 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS);
1324 } 1323 }
1325 1324
1326 // Object literals have two parts. The "static" part on the left contains no
1327 // computed property names, and so we can compute its map ahead of time; see
1328 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1329 // starts with the first computed property name, and continues with all
1330 // properties to its right. All the code from above initializes the static
1331 // component of the object literal, and arranges for the map of the result to
1332 // reflect the static order in which the keys appear. For the dynamic
1333 // properties, we compile them into a series of "SetOwnProperty" runtime
1334 // calls. This will preserve insertion order.
1335 for (; property_index < expr->properties()->length(); property_index++) {
1336 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1337
1338 Expression* value = property->value();
1339 if (!result_saved) {
1340 PushOperand(r0); // Save result on the stack
1341 result_saved = true;
1342 }
1343
1344 __ ldr(r0, MemOperand(sp)); // Duplicate receiver.
1345 PushOperand(r0);
1346
1347 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1348 DCHECK(!property->is_computed_name());
1349 VisitForStackValue(value);
1350 DCHECK(property->emit_store());
1351 CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
1352 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index),
1353 BailoutState::NO_REGISTERS);
1354 } else {
1355 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index));
1356 VisitForStackValue(value);
1357 if (NeedsHomeObject(value)) {
1358 EmitSetHomeObject(value, 2, property->GetSlot());
1359 }
1360
1361 switch (property->kind()) {
1362 case ObjectLiteral::Property::CONSTANT:
1363 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1364 case ObjectLiteral::Property::COMPUTED:
1365 case ObjectLiteral::Property::PROTOTYPE:
1366 UNREACHABLE();
1367 break;
1368
1369 case ObjectLiteral::Property::GETTER:
1370 PushOperand(Smi::FromInt(NONE));
1371 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked);
1372 break;
1373
1374 case ObjectLiteral::Property::SETTER:
1375 PushOperand(Smi::FromInt(NONE));
1376 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked);
1377 break;
1378 }
1379 }
1380 }
1381
1382 if (result_saved) { 1325 if (result_saved) {
1383 context()->PlugTOS(); 1326 context()->PlugTOS();
1384 } else { 1327 } else {
1385 context()->Plug(r0); 1328 context()->Plug(r0);
1386 } 1329 }
1387 } 1330 }
1388 1331
1389 1332
1390 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1333 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1391 Comment cmnt(masm_, "[ ArrayLiteral"); 1334 Comment cmnt(masm_, "[ ArrayLiteral");
(...skipping 1808 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 DCHECK(interrupt_address == 3143 DCHECK(interrupt_address ==
3201 isolate->builtins()->OnStackReplacement()->entry()); 3144 isolate->builtins()->OnStackReplacement()->entry());
3202 return ON_STACK_REPLACEMENT; 3145 return ON_STACK_REPLACEMENT;
3203 } 3146 }
3204 3147
3205 3148
3206 } // namespace internal 3149 } // namespace internal
3207 } // namespace v8 3150 } // namespace v8
3208 3151
3209 #endif // V8_TARGET_ARCH_ARM 3152 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/full-codegen/arm64/full-codegen-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698