| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 int offset = scope()->num_parameters() * kPointerSize; | 223 int offset = scope()->num_parameters() * kPointerSize; |
| 224 __ add(r2, fp, | 224 __ add(r2, fp, |
| 225 Operand(StandardFrameConstants::kCallerSPOffset + offset)); | 225 Operand(StandardFrameConstants::kCallerSPOffset + offset)); |
| 226 __ mov(r1, Operand(Smi::FromInt(scope()->num_parameters()))); | 226 __ mov(r1, Operand(Smi::FromInt(scope()->num_parameters()))); |
| 227 __ Push(r3, r2, r1); | 227 __ Push(r3, r2, r1); |
| 228 | 228 |
| 229 // Arguments to ArgumentsAccessStub: | 229 // Arguments to ArgumentsAccessStub: |
| 230 // function, receiver address, parameter count. | 230 // function, receiver address, parameter count. |
| 231 // The stub will rewrite receiever and parameter count if the previous | 231 // The stub will rewrite receiever and parameter count if the previous |
| 232 // stack frame was an arguments adapter frame. | 232 // stack frame was an arguments adapter frame. |
| 233 ArgumentsAccessStub stub( | 233 ArgumentsAccessStub::Type type; |
| 234 is_strict_mode() ? ArgumentsAccessStub::NEW_STRICT | 234 if (is_strict_mode()) { |
| 235 : ArgumentsAccessStub::NEW_NON_STRICT); | 235 type = ArgumentsAccessStub::NEW_STRICT; |
| 236 } else if (function()->has_duplicate_parameters()) { |
| 237 type = ArgumentsAccessStub::NEW_NON_STRICT_SLOW; |
| 238 } else { |
| 239 type = ArgumentsAccessStub::NEW_NON_STRICT_FAST; |
| 240 } |
| 241 ArgumentsAccessStub stub(type); |
| 236 __ CallStub(&stub); | 242 __ CallStub(&stub); |
| 237 | 243 |
| 238 Variable* arguments_shadow = scope()->arguments_shadow(); | |
| 239 if (arguments_shadow != NULL) { | |
| 240 // Duplicate the value; move-to-slot operation might clobber registers. | |
| 241 __ mov(r3, r0); | |
| 242 Move(arguments_shadow->AsSlot(), r3, r1, r2); | |
| 243 } | |
| 244 Move(arguments->AsSlot(), r0, r1, r2); | 244 Move(arguments->AsSlot(), r0, r1, r2); |
| 245 } | 245 } |
| 246 | 246 |
| 247 if (FLAG_trace) { | 247 if (FLAG_trace) { |
| 248 __ CallRuntime(Runtime::kTraceEnter, 0); | 248 __ CallRuntime(Runtime::kTraceEnter, 0); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Visit the declarations and body unless there is an illegal | 251 // Visit the declarations and body unless there is an illegal |
| 252 // redeclaration. | 252 // redeclaration. |
| 253 if (scope()->HasIllegalRedeclaration()) { | 253 if (scope()->HasIllegalRedeclaration()) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const { | 376 void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const { |
| 377 codegen()->Move(result_register(), slot); | 377 codegen()->Move(result_register(), slot); |
| 378 __ push(result_register()); | 378 __ push(result_register()); |
| 379 } | 379 } |
| 380 | 380 |
| 381 | 381 |
| 382 void FullCodeGenerator::TestContext::Plug(Slot* slot) const { | 382 void FullCodeGenerator::TestContext::Plug(Slot* slot) const { |
| 383 // For simplicity we always test the accumulator register. | 383 // For simplicity we always test the accumulator register. |
| 384 codegen()->Move(result_register(), slot); | 384 codegen()->Move(result_register(), slot); |
| 385 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 385 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 386 codegen()->DoTest(this); | 386 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 387 } | 387 } |
| 388 | 388 |
| 389 | 389 |
| 390 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { | 390 void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const { |
| 391 } | 391 } |
| 392 | 392 |
| 393 | 393 |
| 394 void FullCodeGenerator::AccumulatorValueContext::Plug( | 394 void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 395 Heap::RootListIndex index) const { | 395 Heap::RootListIndex index) const { |
| 396 __ LoadRoot(result_register(), index); | 396 __ LoadRoot(result_register(), index); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 410 true_label_, | 410 true_label_, |
| 411 false_label_); | 411 false_label_); |
| 412 if (index == Heap::kUndefinedValueRootIndex || | 412 if (index == Heap::kUndefinedValueRootIndex || |
| 413 index == Heap::kNullValueRootIndex || | 413 index == Heap::kNullValueRootIndex || |
| 414 index == Heap::kFalseValueRootIndex) { | 414 index == Heap::kFalseValueRootIndex) { |
| 415 if (false_label_ != fall_through_) __ b(false_label_); | 415 if (false_label_ != fall_through_) __ b(false_label_); |
| 416 } else if (index == Heap::kTrueValueRootIndex) { | 416 } else if (index == Heap::kTrueValueRootIndex) { |
| 417 if (true_label_ != fall_through_) __ b(true_label_); | 417 if (true_label_ != fall_through_) __ b(true_label_); |
| 418 } else { | 418 } else { |
| 419 __ LoadRoot(result_register(), index); | 419 __ LoadRoot(result_register(), index); |
| 420 codegen()->DoTest(this); | 420 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 | 424 |
| 425 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { | 425 void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const { |
| 426 } | 426 } |
| 427 | 427 |
| 428 | 428 |
| 429 void FullCodeGenerator::AccumulatorValueContext::Plug( | 429 void FullCodeGenerator::AccumulatorValueContext::Plug( |
| 430 Handle<Object> lit) const { | 430 Handle<Object> lit) const { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 457 } | 457 } |
| 458 } else if (lit->IsSmi()) { | 458 } else if (lit->IsSmi()) { |
| 459 if (Smi::cast(*lit)->value() == 0) { | 459 if (Smi::cast(*lit)->value() == 0) { |
| 460 if (false_label_ != fall_through_) __ b(false_label_); | 460 if (false_label_ != fall_through_) __ b(false_label_); |
| 461 } else { | 461 } else { |
| 462 if (true_label_ != fall_through_) __ b(true_label_); | 462 if (true_label_ != fall_through_) __ b(true_label_); |
| 463 } | 463 } |
| 464 } else { | 464 } else { |
| 465 // For simplicity we always test the accumulator register. | 465 // For simplicity we always test the accumulator register. |
| 466 __ mov(result_register(), Operand(lit)); | 466 __ mov(result_register(), Operand(lit)); |
| 467 codegen()->DoTest(this); | 467 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 468 } | 468 } |
| 469 } | 469 } |
| 470 | 470 |
| 471 | 471 |
| 472 void FullCodeGenerator::EffectContext::DropAndPlug(int count, | 472 void FullCodeGenerator::EffectContext::DropAndPlug(int count, |
| 473 Register reg) const { | 473 Register reg) const { |
| 474 ASSERT(count > 0); | 474 ASSERT(count > 0); |
| 475 __ Drop(count); | 475 __ Drop(count); |
| 476 } | 476 } |
| 477 | 477 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 493 } | 493 } |
| 494 | 494 |
| 495 | 495 |
| 496 void FullCodeGenerator::TestContext::DropAndPlug(int count, | 496 void FullCodeGenerator::TestContext::DropAndPlug(int count, |
| 497 Register reg) const { | 497 Register reg) const { |
| 498 ASSERT(count > 0); | 498 ASSERT(count > 0); |
| 499 // For simplicity we always test the accumulator register. | 499 // For simplicity we always test the accumulator register. |
| 500 __ Drop(count); | 500 __ Drop(count); |
| 501 __ Move(result_register(), reg); | 501 __ Move(result_register(), reg); |
| 502 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); | 502 codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL); |
| 503 codegen()->DoTest(this); | 503 codegen()->DoTest(true_label_, false_label_, fall_through_); |
| 504 } | 504 } |
| 505 | 505 |
| 506 | 506 |
| 507 void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, | 507 void FullCodeGenerator::EffectContext::Plug(Label* materialize_true, |
| 508 Label* materialize_false) const { | 508 Label* materialize_false) const { |
| 509 ASSERT(materialize_true == materialize_false); | 509 ASSERT(materialize_true == materialize_false); |
| 510 __ bind(materialize_true); | 510 __ bind(materialize_true); |
| 511 } | 511 } |
| 512 | 512 |
| 513 | 513 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 true_label_, | 571 true_label_, |
| 572 false_label_); | 572 false_label_); |
| 573 if (flag) { | 573 if (flag) { |
| 574 if (true_label_ != fall_through_) __ b(true_label_); | 574 if (true_label_ != fall_through_) __ b(true_label_); |
| 575 } else { | 575 } else { |
| 576 if (false_label_ != fall_through_) __ b(false_label_); | 576 if (false_label_ != fall_through_) __ b(false_label_); |
| 577 } | 577 } |
| 578 } | 578 } |
| 579 | 579 |
| 580 | 580 |
| 581 void FullCodeGenerator::DoTest(Expression* condition, | 581 void FullCodeGenerator::DoTest(Label* if_true, |
| 582 Label* if_true, | |
| 583 Label* if_false, | 582 Label* if_false, |
| 584 Label* fall_through) { | 583 Label* fall_through) { |
| 585 if (CpuFeatures::IsSupported(VFP3)) { | 584 if (CpuFeatures::IsSupported(VFP3)) { |
| 586 ToBooleanStub stub(result_register()); | 585 ToBooleanStub stub(result_register()); |
| 587 __ CallStub(&stub); | 586 __ CallStub(&stub); |
| 588 __ tst(result_register(), result_register()); | 587 __ tst(result_register(), result_register()); |
| 589 } else { | 588 } else { |
| 590 // Call the runtime to find the boolean value of the source and then | 589 // Call the runtime to find the boolean value of the source and then |
| 591 // translate it into control flow to the pair of labels. | 590 // translate it into control flow to the pair of labels. |
| 592 __ push(result_register()); | 591 __ push(result_register()); |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 EmitCallIC(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); | 1248 EmitCallIC(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); |
| 1250 __ jmp(done); | 1249 __ jmp(done); |
| 1251 } | 1250 } |
| 1252 } | 1251 } |
| 1253 } | 1252 } |
| 1254 } | 1253 } |
| 1255 } | 1254 } |
| 1256 | 1255 |
| 1257 | 1256 |
| 1258 void FullCodeGenerator::EmitVariableLoad(Variable* var) { | 1257 void FullCodeGenerator::EmitVariableLoad(Variable* var) { |
| 1259 // Four cases: non-this global variables, lookup slots, all other | 1258 // Three cases: non-this global variables, lookup slots, and all other |
| 1260 // types of slots, and parameters that rewrite to explicit property | 1259 // types of slots. |
| 1261 // accesses on the arguments object. | |
| 1262 Slot* slot = var->AsSlot(); | 1260 Slot* slot = var->AsSlot(); |
| 1263 Property* property = var->AsProperty(); | 1261 ASSERT((var->is_global() && !var->is_this()) == (slot == NULL)); |
| 1264 | 1262 |
| 1265 if (var->is_global() && !var->is_this()) { | 1263 if (slot == NULL) { |
| 1266 Comment cmnt(masm_, "Global variable"); | 1264 Comment cmnt(masm_, "Global variable"); |
| 1267 // Use inline caching. Variable name is passed in r2 and the global | 1265 // Use inline caching. Variable name is passed in r2 and the global |
| 1268 // object (receiver) in r0. | 1266 // object (receiver) in r0. |
| 1269 __ ldr(r0, GlobalObjectOperand()); | 1267 __ ldr(r0, GlobalObjectOperand()); |
| 1270 __ mov(r2, Operand(var->name())); | 1268 __ mov(r2, Operand(var->name())); |
| 1271 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 1269 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
| 1272 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT, AstNode::kNoNumber); | 1270 EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT, AstNode::kNoNumber); |
| 1273 context()->Plug(r0); | 1271 context()->Plug(r0); |
| 1274 | 1272 |
| 1275 } else if (slot != NULL && slot->type() == Slot::LOOKUP) { | 1273 } else if (slot->type() == Slot::LOOKUP) { |
| 1276 Label done, slow; | 1274 Label done, slow; |
| 1277 | 1275 |
| 1278 // Generate code for loading from variables potentially shadowed | 1276 // Generate code for loading from variables potentially shadowed |
| 1279 // by eval-introduced variables. | 1277 // by eval-introduced variables. |
| 1280 EmitDynamicLoadFromSlotFastCase(slot, NOT_INSIDE_TYPEOF, &slow, &done); | 1278 EmitDynamicLoadFromSlotFastCase(slot, NOT_INSIDE_TYPEOF, &slow, &done); |
| 1281 | 1279 |
| 1282 __ bind(&slow); | 1280 __ bind(&slow); |
| 1283 Comment cmnt(masm_, "Lookup slot"); | 1281 Comment cmnt(masm_, "Lookup slot"); |
| 1284 __ mov(r1, Operand(var->name())); | 1282 __ mov(r1, Operand(var->name())); |
| 1285 __ Push(cp, r1); // Context and name. | 1283 __ Push(cp, r1); // Context and name. |
| 1286 __ CallRuntime(Runtime::kLoadContextSlot, 2); | 1284 __ CallRuntime(Runtime::kLoadContextSlot, 2); |
| 1287 __ bind(&done); | 1285 __ bind(&done); |
| 1288 | 1286 |
| 1289 context()->Plug(r0); | 1287 context()->Plug(r0); |
| 1290 | 1288 |
| 1291 } else if (slot != NULL) { | 1289 } else { |
| 1292 Comment cmnt(masm_, (slot->type() == Slot::CONTEXT) | 1290 Comment cmnt(masm_, (slot->type() == Slot::CONTEXT) |
| 1293 ? "Context slot" | 1291 ? "Context slot" |
| 1294 : "Stack slot"); | 1292 : "Stack slot"); |
| 1295 if (var->mode() == Variable::CONST) { | 1293 if (var->mode() == Variable::CONST) { |
| 1296 // Constants may be the hole value if they have not been initialized. | 1294 // Constants may be the hole value if they have not been initialized. |
| 1297 // Unhole them. | 1295 // Unhole them. |
| 1298 MemOperand slot_operand = EmitSlotSearch(slot, r0); | 1296 MemOperand slot_operand = EmitSlotSearch(slot, r0); |
| 1299 __ ldr(r0, slot_operand); | 1297 __ ldr(r0, slot_operand); |
| 1300 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); | 1298 __ LoadRoot(ip, Heap::kTheHoleValueRootIndex); |
| 1301 __ cmp(r0, ip); | 1299 __ cmp(r0, ip); |
| 1302 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); | 1300 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
| 1303 context()->Plug(r0); | 1301 context()->Plug(r0); |
| 1304 } else { | 1302 } else { |
| 1305 context()->Plug(slot); | 1303 context()->Plug(slot); |
| 1306 } | 1304 } |
| 1307 } else { | |
| 1308 Comment cmnt(masm_, "Rewritten parameter"); | |
| 1309 ASSERT_NOT_NULL(property); | |
| 1310 // Rewritten parameter accesses are of the form "slot[literal]". | |
| 1311 | |
| 1312 // Assert that the object is in a slot. | |
| 1313 Variable* object_var = property->obj()->AsVariableProxy()->AsVariable(); | |
| 1314 ASSERT_NOT_NULL(object_var); | |
| 1315 Slot* object_slot = object_var->AsSlot(); | |
| 1316 ASSERT_NOT_NULL(object_slot); | |
| 1317 | |
| 1318 // Load the object. | |
| 1319 Move(r1, object_slot); | |
| 1320 | |
| 1321 // Assert that the key is a smi. | |
| 1322 Literal* key_literal = property->key()->AsLiteral(); | |
| 1323 ASSERT_NOT_NULL(key_literal); | |
| 1324 ASSERT(key_literal->handle()->IsSmi()); | |
| 1325 | |
| 1326 // Load the key. | |
| 1327 __ mov(r0, Operand(key_literal->handle())); | |
| 1328 | |
| 1329 // Call keyed load IC. It has arguments key and receiver in r0 and r1. | |
| 1330 Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize(); | |
| 1331 EmitCallIC(ic, RelocInfo::CODE_TARGET, GetPropertyId(property)); | |
| 1332 context()->Plug(r0); | |
| 1333 } | 1305 } |
| 1334 } | 1306 } |
| 1335 | 1307 |
| 1336 | 1308 |
| 1337 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { | 1309 void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 1338 Comment cmnt(masm_, "[ RegExpLiteral"); | 1310 Comment cmnt(masm_, "[ RegExpLiteral"); |
| 1339 Label materialized; | 1311 Label materialized; |
| 1340 // Registers will be used as follows: | 1312 // Registers will be used as follows: |
| 1341 // r5 = materialized value (RegExp literal) | 1313 // r5 = materialized value (RegExp literal) |
| 1342 // r4 = JS function, literals array | 1314 // r4 = JS function, literals array |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 void FullCodeGenerator::VisitAssignment(Assignment* expr) { | 1535 void FullCodeGenerator::VisitAssignment(Assignment* expr) { |
| 1564 Comment cmnt(masm_, "[ Assignment"); | 1536 Comment cmnt(masm_, "[ Assignment"); |
| 1565 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' | 1537 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 1566 // on the left-hand side. | 1538 // on the left-hand side. |
| 1567 if (!expr->target()->IsValidLeftHandSide()) { | 1539 if (!expr->target()->IsValidLeftHandSide()) { |
| 1568 VisitForEffect(expr->target()); | 1540 VisitForEffect(expr->target()); |
| 1569 return; | 1541 return; |
| 1570 } | 1542 } |
| 1571 | 1543 |
| 1572 // Left-hand side can only be a property, a global or a (parameter or local) | 1544 // Left-hand side can only be a property, a global or a (parameter or local) |
| 1573 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. | 1545 // slot. |
| 1574 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 1546 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 1575 LhsKind assign_type = VARIABLE; | 1547 LhsKind assign_type = VARIABLE; |
| 1576 Property* property = expr->target()->AsProperty(); | 1548 Property* property = expr->target()->AsProperty(); |
| 1577 if (property != NULL) { | 1549 if (property != NULL) { |
| 1578 assign_type = (property->key()->IsPropertyName()) | 1550 assign_type = (property->key()->IsPropertyName()) |
| 1579 ? NAMED_PROPERTY | 1551 ? NAMED_PROPERTY |
| 1580 : KEYED_PROPERTY; | 1552 : KEYED_PROPERTY; |
| 1581 } | 1553 } |
| 1582 | 1554 |
| 1583 // Evaluate LHS expression. | 1555 // Evaluate LHS expression. |
| 1584 switch (assign_type) { | 1556 switch (assign_type) { |
| 1585 case VARIABLE: | 1557 case VARIABLE: |
| 1586 // Nothing to do here. | 1558 // Nothing to do here. |
| 1587 break; | 1559 break; |
| 1588 case NAMED_PROPERTY: | 1560 case NAMED_PROPERTY: |
| 1589 if (expr->is_compound()) { | 1561 if (expr->is_compound()) { |
| 1590 // We need the receiver both on the stack and in the accumulator. | 1562 // We need the receiver both on the stack and in the accumulator. |
| 1591 VisitForAccumulatorValue(property->obj()); | 1563 VisitForAccumulatorValue(property->obj()); |
| 1592 __ push(result_register()); | 1564 __ push(result_register()); |
| 1593 } else { | 1565 } else { |
| 1594 VisitForStackValue(property->obj()); | 1566 VisitForStackValue(property->obj()); |
| 1595 } | 1567 } |
| 1596 break; | 1568 break; |
| 1597 case KEYED_PROPERTY: | 1569 case KEYED_PROPERTY: |
| 1598 if (expr->is_compound()) { | 1570 if (expr->is_compound()) { |
| 1599 if (property->is_arguments_access()) { | 1571 VisitForStackValue(property->obj()); |
| 1600 VariableProxy* obj_proxy = property->obj()->AsVariableProxy(); | 1572 VisitForAccumulatorValue(property->key()); |
| 1601 __ ldr(r0, EmitSlotSearch(obj_proxy->var()->AsSlot(), r0)); | |
| 1602 __ push(r0); | |
| 1603 __ mov(r0, Operand(property->key()->AsLiteral()->handle())); | |
| 1604 } else { | |
| 1605 VisitForStackValue(property->obj()); | |
| 1606 VisitForAccumulatorValue(property->key()); | |
| 1607 } | |
| 1608 __ ldr(r1, MemOperand(sp, 0)); | 1573 __ ldr(r1, MemOperand(sp, 0)); |
| 1609 __ push(r0); | 1574 __ push(r0); |
| 1610 } else { | 1575 } else { |
| 1611 if (property->is_arguments_access()) { | 1576 VisitForStackValue(property->obj()); |
| 1612 VariableProxy* obj_proxy = property->obj()->AsVariableProxy(); | 1577 VisitForStackValue(property->key()); |
| 1613 __ ldr(r1, EmitSlotSearch(obj_proxy->var()->AsSlot(), r0)); | |
| 1614 __ mov(r0, Operand(property->key()->AsLiteral()->handle())); | |
| 1615 __ Push(r1, r0); | |
| 1616 } else { | |
| 1617 VisitForStackValue(property->obj()); | |
| 1618 VisitForStackValue(property->key()); | |
| 1619 } | |
| 1620 } | 1578 } |
| 1621 break; | 1579 break; |
| 1622 } | 1580 } |
| 1623 | 1581 |
| 1624 // For compound assignments we need another deoptimization point after the | 1582 // For compound assignments we need another deoptimization point after the |
| 1625 // variable/property load. | 1583 // variable/property load. |
| 1626 if (expr->is_compound()) { | 1584 if (expr->is_compound()) { |
| 1627 { AccumulatorValueContext context(this); | 1585 { AccumulatorValueContext context(this); |
| 1628 switch (assign_type) { | 1586 switch (assign_type) { |
| 1629 case VARIABLE: | 1587 case VARIABLE: |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1816 | 1774 |
| 1817 void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { | 1775 void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) { |
| 1818 // Invalid left-hand sides are rewritten to have a 'throw | 1776 // Invalid left-hand sides are rewritten to have a 'throw |
| 1819 // ReferenceError' on the left-hand side. | 1777 // ReferenceError' on the left-hand side. |
| 1820 if (!expr->IsValidLeftHandSide()) { | 1778 if (!expr->IsValidLeftHandSide()) { |
| 1821 VisitForEffect(expr); | 1779 VisitForEffect(expr); |
| 1822 return; | 1780 return; |
| 1823 } | 1781 } |
| 1824 | 1782 |
| 1825 // Left-hand side can only be a property, a global or a (parameter or local) | 1783 // Left-hand side can only be a property, a global or a (parameter or local) |
| 1826 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. | 1784 // slot. |
| 1827 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 1785 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 1828 LhsKind assign_type = VARIABLE; | 1786 LhsKind assign_type = VARIABLE; |
| 1829 Property* prop = expr->AsProperty(); | 1787 Property* prop = expr->AsProperty(); |
| 1830 if (prop != NULL) { | 1788 if (prop != NULL) { |
| 1831 assign_type = (prop->key()->IsPropertyName()) | 1789 assign_type = (prop->key()->IsPropertyName()) |
| 1832 ? NAMED_PROPERTY | 1790 ? NAMED_PROPERTY |
| 1833 : KEYED_PROPERTY; | 1791 : KEYED_PROPERTY; |
| 1834 } | 1792 } |
| 1835 | 1793 |
| 1836 switch (assign_type) { | 1794 switch (assign_type) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1847 __ pop(r0); // Restore value. | 1805 __ pop(r0); // Restore value. |
| 1848 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); | 1806 __ mov(r2, Operand(prop->key()->AsLiteral()->handle())); |
| 1849 Handle<Code> ic = is_strict_mode() | 1807 Handle<Code> ic = is_strict_mode() |
| 1850 ? isolate()->builtins()->StoreIC_Initialize_Strict() | 1808 ? isolate()->builtins()->StoreIC_Initialize_Strict() |
| 1851 : isolate()->builtins()->StoreIC_Initialize(); | 1809 : isolate()->builtins()->StoreIC_Initialize(); |
| 1852 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); | 1810 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); |
| 1853 break; | 1811 break; |
| 1854 } | 1812 } |
| 1855 case KEYED_PROPERTY: { | 1813 case KEYED_PROPERTY: { |
| 1856 __ push(r0); // Preserve value. | 1814 __ push(r0); // Preserve value. |
| 1857 if (prop->is_synthetic()) { | 1815 VisitForStackValue(prop->obj()); |
| 1858 ASSERT(prop->obj()->AsVariableProxy() != NULL); | 1816 VisitForAccumulatorValue(prop->key()); |
| 1859 ASSERT(prop->key()->AsLiteral() != NULL); | 1817 __ mov(r1, r0); |
| 1860 { AccumulatorValueContext for_object(this); | 1818 __ pop(r2); |
| 1861 EmitVariableLoad(prop->obj()->AsVariableProxy()->var()); | |
| 1862 } | |
| 1863 __ mov(r2, r0); | |
| 1864 __ mov(r1, Operand(prop->key()->AsLiteral()->handle())); | |
| 1865 } else { | |
| 1866 VisitForStackValue(prop->obj()); | |
| 1867 VisitForAccumulatorValue(prop->key()); | |
| 1868 __ mov(r1, r0); | |
| 1869 __ pop(r2); | |
| 1870 } | |
| 1871 __ pop(r0); // Restore value. | 1819 __ pop(r0); // Restore value. |
| 1872 Handle<Code> ic = is_strict_mode() | 1820 Handle<Code> ic = is_strict_mode() |
| 1873 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() | 1821 ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict() |
| 1874 : isolate()->builtins()->KeyedStoreIC_Initialize(); | 1822 : isolate()->builtins()->KeyedStoreIC_Initialize(); |
| 1875 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); | 1823 EmitCallIC(ic, RelocInfo::CODE_TARGET, AstNode::kNoNumber); |
| 1876 break; | 1824 break; |
| 1877 } | 1825 } |
| 1878 } | 1826 } |
| 1879 PrepareForBailoutForId(bailout_ast_id, TOS_REG); | 1827 PrepareForBailoutForId(bailout_ast_id, TOS_REG); |
| 1880 context()->Plug(r0); | 1828 context()->Plug(r0); |
| 1881 } | 1829 } |
| 1882 | 1830 |
| 1883 | 1831 |
| 1884 void FullCodeGenerator::EmitVariableAssignment(Variable* var, | 1832 void FullCodeGenerator::EmitVariableAssignment(Variable* var, |
| 1885 Token::Value op) { | 1833 Token::Value op) { |
| 1886 // Left-hand sides that rewrite to explicit property accesses do not reach | |
| 1887 // here. | |
| 1888 ASSERT(var != NULL); | 1834 ASSERT(var != NULL); |
| 1889 ASSERT(var->is_global() || var->AsSlot() != NULL); | 1835 ASSERT(var->is_global() || var->AsSlot() != NULL); |
| 1890 | 1836 |
| 1891 if (var->is_global()) { | 1837 if (var->is_global()) { |
| 1892 ASSERT(!var->is_this()); | 1838 ASSERT(!var->is_this()); |
| 1893 // Assignment to a global variable. Use inline caching for the | 1839 // Assignment to a global variable. Use inline caching for the |
| 1894 // assignment. Right-hand-side value is passed in r0, variable name in | 1840 // assignment. Right-hand-side value is passed in r0, variable name in |
| 1895 // r2, and the global object in r1. | 1841 // r2, and the global object in r1. |
| 1896 __ mov(r2, Operand(var->name())); | 1842 __ mov(r2, Operand(var->name())); |
| 1897 __ ldr(r1, GlobalObjectOperand()); | 1843 __ ldr(r1, GlobalObjectOperand()); |
| (...skipping 1919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3817 SetSourcePosition(expr->position()); | 3763 SetSourcePosition(expr->position()); |
| 3818 | 3764 |
| 3819 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' | 3765 // Invalid left-hand sides are rewritten to have a 'throw ReferenceError' |
| 3820 // as the left-hand side. | 3766 // as the left-hand side. |
| 3821 if (!expr->expression()->IsValidLeftHandSide()) { | 3767 if (!expr->expression()->IsValidLeftHandSide()) { |
| 3822 VisitForEffect(expr->expression()); | 3768 VisitForEffect(expr->expression()); |
| 3823 return; | 3769 return; |
| 3824 } | 3770 } |
| 3825 | 3771 |
| 3826 // Expression can only be a property, a global or a (parameter or local) | 3772 // Expression can only be a property, a global or a (parameter or local) |
| 3827 // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY. | 3773 // slot. |
| 3828 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; | 3774 enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY }; |
| 3829 LhsKind assign_type = VARIABLE; | 3775 LhsKind assign_type = VARIABLE; |
| 3830 Property* prop = expr->expression()->AsProperty(); | 3776 Property* prop = expr->expression()->AsProperty(); |
| 3831 // In case of a property we use the uninitialized expression context | 3777 // In case of a property we use the uninitialized expression context |
| 3832 // of the key to detect a named property. | 3778 // of the key to detect a named property. |
| 3833 if (prop != NULL) { | 3779 if (prop != NULL) { |
| 3834 assign_type = | 3780 assign_type = |
| 3835 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; | 3781 (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY; |
| 3836 } | 3782 } |
| 3837 | 3783 |
| 3838 // Evaluate expression and get value. | 3784 // Evaluate expression and get value. |
| 3839 if (assign_type == VARIABLE) { | 3785 if (assign_type == VARIABLE) { |
| 3840 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); | 3786 ASSERT(expr->expression()->AsVariableProxy()->var() != NULL); |
| 3841 AccumulatorValueContext context(this); | 3787 AccumulatorValueContext context(this); |
| 3842 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); | 3788 EmitVariableLoad(expr->expression()->AsVariableProxy()->var()); |
| 3843 } else { | 3789 } else { |
| 3844 // Reserve space for result of postfix operation. | 3790 // Reserve space for result of postfix operation. |
| 3845 if (expr->is_postfix() && !context()->IsEffect()) { | 3791 if (expr->is_postfix() && !context()->IsEffect()) { |
| 3846 __ mov(ip, Operand(Smi::FromInt(0))); | 3792 __ mov(ip, Operand(Smi::FromInt(0))); |
| 3847 __ push(ip); | 3793 __ push(ip); |
| 3848 } | 3794 } |
| 3849 if (assign_type == NAMED_PROPERTY) { | 3795 if (assign_type == NAMED_PROPERTY) { |
| 3850 // Put the object both on the stack and in the accumulator. | 3796 // Put the object both on the stack and in the accumulator. |
| 3851 VisitForAccumulatorValue(prop->obj()); | 3797 VisitForAccumulatorValue(prop->obj()); |
| 3852 __ push(r0); | 3798 __ push(r0); |
| 3853 EmitNamedPropertyLoad(prop); | 3799 EmitNamedPropertyLoad(prop); |
| 3854 } else { | 3800 } else { |
| 3855 if (prop->is_arguments_access()) { | 3801 VisitForStackValue(prop->obj()); |
| 3856 VariableProxy* obj_proxy = prop->obj()->AsVariableProxy(); | 3802 VisitForAccumulatorValue(prop->key()); |
| 3857 __ ldr(r0, EmitSlotSearch(obj_proxy->var()->AsSlot(), r0)); | |
| 3858 __ push(r0); | |
| 3859 __ mov(r0, Operand(prop->key()->AsLiteral()->handle())); | |
| 3860 } else { | |
| 3861 VisitForStackValue(prop->obj()); | |
| 3862 VisitForAccumulatorValue(prop->key()); | |
| 3863 } | |
| 3864 __ ldr(r1, MemOperand(sp, 0)); | 3803 __ ldr(r1, MemOperand(sp, 0)); |
| 3865 __ push(r0); | 3804 __ push(r0); |
| 3866 EmitKeyedPropertyLoad(prop); | 3805 EmitKeyedPropertyLoad(prop); |
| 3867 } | 3806 } |
| 3868 } | 3807 } |
| 3869 | 3808 |
| 3870 // We need a second deoptimization point after loading the value | 3809 // We need a second deoptimization point after loading the value |
| 3871 // in case evaluating the property load my have a side effect. | 3810 // in case evaluating the property load my have a side effect. |
| 3872 if (assign_type == VARIABLE) { | 3811 if (assign_type == VARIABLE) { |
| 3873 PrepareForBailout(expr->expression(), TOS_REG); | 3812 PrepareForBailout(expr->expression(), TOS_REG); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4365 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 4304 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 4366 __ add(pc, r1, Operand(masm_->CodeObject())); | 4305 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 4367 } | 4306 } |
| 4368 | 4307 |
| 4369 | 4308 |
| 4370 #undef __ | 4309 #undef __ |
| 4371 | 4310 |
| 4372 } } // namespace v8::internal | 4311 } } // namespace v8::internal |
| 4373 | 4312 |
| 4374 #endif // V8_TARGET_ARCH_ARM | 4313 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |