Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 Comment cmnt(masm_, "[ ExpressionStatement"); | 142 Comment cmnt(masm_, "[ ExpressionStatement"); |
| 143 SetStatementPosition(stmt); | 143 SetStatementPosition(stmt); |
| 144 Visit(stmt->expression()); | 144 Visit(stmt->expression()); |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 148 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
| 149 Comment cmnt(masm_, "[ ReturnStatement"); | 149 Comment cmnt(masm_, "[ ReturnStatement"); |
| 150 SetStatementPosition(stmt); | 150 SetStatementPosition(stmt); |
| 151 Expression* expr = stmt->expression(); | 151 Expression* expr = stmt->expression(); |
| 152 Visit(expr); | 152 // Complete the statement based on the type of the subexpression. |
| 153 | 153 if (expr->AsLiteral() != NULL) { |
| 154 // Complete the statement based on the location of the subexpression. | 154 __ mov(r0, Operand(expr->AsLiteral()->handle())); |
| 155 Location source = expr->location(); | 155 } else { |
| 156 ASSERT(!source.is_nowhere()); | 156 Visit(expr); |
| 157 if (source.is_temporary()) { | 157 ASSERT(expr->location().is_temporary()); |
| 158 __ pop(r0); | 158 __ pop(r0); |
| 159 } else { | |
| 160 ASSERT(source.is_constant()); | |
| 161 ASSERT(expr->AsLiteral() != NULL); | |
| 162 __ mov(r0, Operand(expr->AsLiteral()->handle())); | |
| 163 } | 159 } |
| 164 | 160 |
| 165 if (FLAG_trace) { | 161 if (FLAG_trace) { |
| 166 // Push the return value on the stack as the parameter. | |
| 167 // Runtime::TraceExit returns its parameter in r0. | |
| 168 __ push(r0); | 162 __ push(r0); |
| 169 __ CallRuntime(Runtime::kTraceExit, 1); | 163 __ CallRuntime(Runtime::kTraceExit, 1); |
| 170 } | 164 } |
| 171 | 165 |
| 172 __ RecordJSReturn(); | 166 __ RecordJSReturn(); |
| 173 __ mov(sp, fp); | 167 __ mov(sp, fp); |
| 174 __ ldm(ia_w, sp, fp.bit() | lr.bit()); | 168 __ ldm(ia_w, sp, fp.bit() | lr.bit()); |
| 175 int num_parameters = function_->scope()->num_parameters(); | 169 int num_parameters = function_->scope()->num_parameters(); |
| 176 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); | 170 __ add(sp, sp, Operand((num_parameters + 1) * kPointerSize)); |
| 177 __ Jump(lr); | 171 __ Jump(lr); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 if (expr->location().is_temporary()) { | 221 if (expr->location().is_temporary()) { |
| 228 __ ldr(ip, MemOperand(fp, SlotOffset(slot))); | 222 __ ldr(ip, MemOperand(fp, SlotOffset(slot))); |
| 229 __ push(ip); | 223 __ push(ip); |
| 230 } else { | 224 } else { |
| 231 ASSERT(expr->location().is_nowhere()); | 225 ASSERT(expr->location().is_nowhere()); |
| 232 } | 226 } |
| 233 } | 227 } |
| 234 } | 228 } |
| 235 | 229 |
| 236 | 230 |
| 231 void FastCodeGenerator::VisitLiteral(Literal* expr) { | |
| 232 if (expr->location().is_temporary()) { | |
| 233 __ mov(ip, Operand(expr->AsLiteral()->handle())); | |
| 234 __ push(ip); | |
| 235 } else { | |
| 236 ASSERT(expr->location().is_nowhere()); | |
| 237 } | |
| 238 } | |
| 239 | |
| 240 | |
| 237 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 241 void FastCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 238 Comment cmnt(masm_, "[ ObjectLiteral"); | 242 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 239 Label boilerplate_exists; | 243 Label boilerplate_exists; |
| 240 __ ldr(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); | 244 __ ldr(r2, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
| 241 // r2 = literal array (0). | 245 // r2 = literal array (0). |
| 242 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset)); | 246 __ ldr(r2, FieldMemOperand(r2, JSFunction::kLiteralsOffset)); |
| 243 int literal_offset = | 247 int literal_offset = |
| 244 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; | 248 FixedArray::kHeaderSize + expr->literal_index() * kPointerSize; |
| 245 __ ldr(r0, FieldMemOperand(r2, literal_offset)); | 249 __ ldr(r0, FieldMemOperand(r2, literal_offset)); |
| 246 // Check whether we need to materialize the object literal boilerplate. | 250 // Check whether we need to materialize the object literal boilerplate. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 __ push(r0); // Save result on stack | 285 __ push(r0); // Save result on stack |
| 282 result_saved = true; | 286 result_saved = true; |
| 283 } | 287 } |
| 284 switch (property->kind()) { | 288 switch (property->kind()) { |
| 285 case ObjectLiteral::Property::MATERIALIZED_LITERAL: // fall through | 289 case ObjectLiteral::Property::MATERIALIZED_LITERAL: // fall through |
| 286 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); | 290 ASSERT(!CompileTimeValue::IsCompileTimeValue(property->value())); |
| 287 case ObjectLiteral::Property::COMPUTED: // fall through | 291 case ObjectLiteral::Property::COMPUTED: // fall through |
| 288 case ObjectLiteral::Property::PROTOTYPE: | 292 case ObjectLiteral::Property::PROTOTYPE: |
| 289 __ push(r0); | 293 __ push(r0); |
| 290 Visit(key); | 294 Visit(key); |
| 291 if (key->location().is_constant()) { | 295 ASSERT(key->location().is_temporary()); |
| 292 __ mov(r1, Operand(key->handle())); | |
| 293 __ push(r1); | |
| 294 } | |
| 295 Visit(value); | 296 Visit(value); |
| 296 ASSERT(value->location().is_temporary()); | 297 ASSERT(value->location().is_temporary()); |
| 297 __ CallRuntime(Runtime::kSetProperty, 3); | 298 __ CallRuntime(Runtime::kSetProperty, 3); |
| 298 __ ldr(r0, MemOperand(sp)); // Restore result into r0 | 299 __ ldr(r0, MemOperand(sp)); // Restore result into r0 |
| 299 break; | 300 break; |
| 300 case ObjectLiteral::Property::SETTER: // fall through | 301 case ObjectLiteral::Property::SETTER: // fall through |
| 301 case ObjectLiteral::Property::GETTER: | 302 case ObjectLiteral::Property::GETTER: |
| 302 __ push(r0); | 303 __ push(r0); |
| 303 Visit(key); | 304 Visit(key); |
| 304 if (key->location().is_constant()) { | 305 ASSERT(key->location().is_temporary()); |
| 305 __ mov(r1, Operand(key->handle())); | |
| 306 __ push(r1); | |
| 307 } | |
| 308 __ mov(r1, Operand(property->kind() == ObjectLiteral::Property::SETTER ? | 306 __ mov(r1, Operand(property->kind() == ObjectLiteral::Property::SETTER ? |
| 309 Smi::FromInt(1) : | 307 Smi::FromInt(1) : |
| 310 Smi::FromInt(0))); | 308 Smi::FromInt(0))); |
| 311 __ push(r1); | 309 __ push(r1); |
| 312 Visit(value); | 310 Visit(value); |
| 313 ASSERT(value->location().is_temporary()); | 311 ASSERT(value->location().is_temporary()); |
| 314 __ CallRuntime(Runtime::kDefineAccessor, 4); | 312 __ CallRuntime(Runtime::kDefineAccessor, 4); |
| 315 __ ldr(r0, MemOperand(sp)); // Restore result into r0 | 313 __ ldr(r0, MemOperand(sp)); // Restore result into r0 |
| 316 break; | 314 break; |
| 317 default: UNREACHABLE(); | 315 default: UNREACHABLE(); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 426 __ pop(); | 424 __ pop(); |
| 427 } else if (destination.is_temporary() && !result_saved) { | 425 } else if (destination.is_temporary() && !result_saved) { |
| 428 __ push(r0); | 426 __ push(r0); |
| 429 } | 427 } |
| 430 } | 428 } |
| 431 | 429 |
| 432 | 430 |
| 433 void FastCodeGenerator::VisitAssignment(Assignment* expr) { | 431 void FastCodeGenerator::VisitAssignment(Assignment* expr) { |
| 434 Comment cmnt(masm_, "[ Assignment"); | 432 Comment cmnt(masm_, "[ Assignment"); |
| 435 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); | 433 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); |
| 436 Expression* rhs = expr->value(); | |
| 437 Visit(rhs); | |
| 438 | 434 |
| 439 // Left-hand side can only be a global or a (parameter or local) slot. | 435 // Left-hand side can only be a global or a (parameter or local) slot. |
| 440 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 436 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 441 ASSERT(var != NULL); | 437 ASSERT(var != NULL); |
| 442 ASSERT(var->is_global() || var->slot() != NULL); | 438 ASSERT(var->is_global() || var->slot() != NULL); |
| 443 | 439 |
| 444 // Complete the assignment based on the location of the right-hand-side | 440 Expression* rhs = expr->value(); |
| 445 // value and the desired location of the assignment value. | |
| 446 Location destination = expr->location(); | 441 Location destination = expr->location(); |
| 447 Location source = rhs->location(); | |
| 448 ASSERT(!destination.is_constant()); | |
| 449 ASSERT(!source.is_nowhere()); | |
| 450 | |
| 451 if (var->is_global()) { | 442 if (var->is_global()) { |
| 452 // Assignment to a global variable, use inline caching. Right-hand-side | 443 // Assignment to a global variable, use inline caching. Right-hand-side |
| 453 // value is passed in r0, variable name in r2, and the global object on | 444 // value is passed in r0, variable name in r2, and the global object on |
| 454 // the stack. | 445 // the stack. |
| 455 if (source.is_temporary()) { | 446 |
| 447 // Code for the right-hand-side expression depends on its type. | |
| 448 if (rhs->AsLiteral() != NULL) { | |
| 449 __ mov(r0, Operand(rhs->AsLiteral()->handle())); | |
| 450 } else { | |
| 451 ASSERT(rhs->location().is_temporary()); | |
| 452 Visit(rhs); | |
| 456 __ pop(r0); | 453 __ pop(r0); |
| 457 } else { | |
| 458 ASSERT(source.is_constant()); | |
| 459 ASSERT(rhs->AsLiteral() != NULL); | |
| 460 __ mov(r0, Operand(rhs->AsLiteral()->handle())); | |
| 461 } | 454 } |
| 462 __ mov(r2, Operand(var->name())); | 455 __ mov(r2, Operand(var->name())); |
| 463 __ ldr(ip, CodeGenerator::GlobalObject()); | 456 __ ldr(ip, CodeGenerator::GlobalObject()); |
| 464 __ push(ip); | 457 __ push(ip); |
| 465 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 458 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 466 __ Call(ic, RelocInfo::CODE_TARGET); | 459 __ Call(ic, RelocInfo::CODE_TARGET); |
| 467 // Overwrite the global object on the stack with the result if needed. | 460 // Overwrite the global object on the stack with the result if needed. |
| 468 if (destination.is_temporary()) { | 461 if (destination.is_temporary()) { |
| 469 __ str(r0, MemOperand(sp)); | 462 __ str(r0, MemOperand(sp)); |
| 470 } else { | 463 } else { |
| 471 ASSERT(destination.is_nowhere()); | 464 ASSERT(destination.is_nowhere()); |
| 472 __ pop(); | 465 __ pop(); |
| 473 } | 466 } |
| 474 | 467 |
| 475 } else { | 468 } else { |
| 476 if (source.is_temporary()) { | 469 // Local or parameter assignment. |
| 470 | |
| 471 // Code for the right-hand side expression depends on its type. | |
| 472 if (rhs->AsLiteral() != NULL) { | |
| 473 // Two cases: 'temp <- (var = constant)', or 'var = constant' with a | |
| 474 // discarded result. Always perform the assignment. | |
| 475 __ mov(ip, Operand(rhs->AsLiteral()->handle())); | |
| 476 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); | |
| 477 if (destination.is_temporary()) { | |
| 478 // Case 'temp <- (var = constant)'. Save result. | |
| 479 __ push(ip); | |
| 480 } | |
|
fschneider
2009/10/26 17:57:20
Add an assert here to be consistent with the rest
| |
| 481 } else { | |
| 482 ASSERT(rhs->location().is_temporary()); | |
| 483 Visit(rhs); | |
| 477 if (destination.is_temporary()) { | 484 if (destination.is_temporary()) { |
| 478 // Case 'temp1 <- (var = temp0)'. Preserve right-hand-side | 485 // Case 'temp1 <- (var = temp0)'. Preserve right-hand-side |
| 479 // temporary on the stack. | 486 // temporary on the stack. |
| 480 __ ldr(ip, MemOperand(sp)); | 487 __ ldr(ip, MemOperand(sp)); |
| 481 } else { | 488 } else { |
| 482 ASSERT(destination.is_nowhere()); | 489 ASSERT(destination.is_nowhere()); |
| 483 // Case 'var = temp'. Discard right-hand-side temporary. | 490 // Case 'var = temp'. Discard right-hand-side temporary. |
| 484 __ pop(ip); | 491 __ pop(ip); |
| 485 } | 492 } |
| 486 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); | 493 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); |
| 487 } else { | |
| 488 ASSERT(source.is_constant()); | |
| 489 ASSERT(rhs->AsLiteral() != NULL); | |
| 490 // Two cases: 'temp <- (var = constant)', or 'var = constant' with a | |
| 491 // discarded result. Always perform the assignment. | |
| 492 __ mov(ip, Operand(rhs->AsLiteral()->handle())); | |
| 493 __ str(ip, MemOperand(fp, SlotOffset(var->slot()))); | |
| 494 if (destination.is_temporary()) { | |
| 495 // Case 'temp <- (var = constant)'. Save result. | |
| 496 __ push(ip); | |
| 497 } | |
| 498 } | 494 } |
| 499 } | 495 } |
| 500 } | 496 } |
| 501 | 497 |
| 502 | 498 |
| 503 void FastCodeGenerator::VisitCall(Call* expr) { | 499 void FastCodeGenerator::VisitCall(Call* expr) { |
| 504 Comment cmnt(masm_, "[ Call"); | 500 Comment cmnt(masm_, "[ Call"); |
| 505 Expression* fun = expr->expression(); | 501 Expression* fun = expr->expression(); |
| 506 ZoneList<Expression*>* args = expr->arguments(); | 502 ZoneList<Expression*>* args = expr->arguments(); |
| 507 Variable* var = fun->AsVariableProxy()->AsVariable(); | 503 Variable* var = fun->AsVariableProxy()->AsVariable(); |
| 508 ASSERT(var != NULL && !var->is_this() && var->is_global()); | 504 ASSERT(var != NULL && !var->is_this() && var->is_global()); |
| 509 ASSERT(!var->is_possibly_eval()); | 505 ASSERT(!var->is_possibly_eval()); |
| 510 | 506 |
| 511 __ mov(r1, Operand(var->name())); | 507 __ mov(r1, Operand(var->name())); |
| 512 // Push global object as receiver. | 508 // Push global object as receiver. |
| 513 __ ldr(r0, CodeGenerator::GlobalObject()); | 509 __ ldr(r0, CodeGenerator::GlobalObject()); |
| 514 __ stm(db_w, sp, r1.bit() | r0.bit()); | 510 __ stm(db_w, sp, r1.bit() | r0.bit()); |
| 515 int arg_count = args->length(); | 511 int arg_count = args->length(); |
| 516 for (int i = 0; i < arg_count; i++) { | 512 for (int i = 0; i < arg_count; i++) { |
| 517 Visit(args->at(i)); | 513 Visit(args->at(i)); |
| 518 ASSERT(!args->at(i)->location().is_nowhere()); | 514 ASSERT(args->at(i)->location().is_temporary()); |
| 519 if (args->at(i)->location().is_constant()) { | |
| 520 ASSERT(args->at(i)->AsLiteral() != NULL); | |
| 521 __ mov(r0, Operand(args->at(i)->AsLiteral()->handle())); | |
| 522 __ push(r0); | |
| 523 } | |
| 524 } | 515 } |
| 525 // Record source position for debugger | 516 // Record source position for debugger |
| 526 SetSourcePosition(expr->position()); | 517 SetSourcePosition(expr->position()); |
| 527 // Call the IC initialization code. | 518 // Call the IC initialization code. |
| 528 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, | 519 Handle<Code> ic = CodeGenerator::ComputeCallInitialize(arg_count, |
| 529 NOT_IN_LOOP); | 520 NOT_IN_LOOP); |
| 530 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); | 521 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); |
| 531 // Restore context register. | 522 // Restore context register. |
| 532 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 523 __ ldr(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 533 if (expr->location().is_temporary()) { | 524 if (expr->location().is_temporary()) { |
| 534 __ str(r0, MemOperand(sp)); | 525 __ str(r0, MemOperand(sp)); |
| 535 } else { | 526 } else { |
| 536 ASSERT(expr->location().is_nowhere()); | 527 ASSERT(expr->location().is_nowhere()); |
| 537 __ pop(); | 528 __ pop(); |
| 538 } | 529 } |
| 539 } | 530 } |
| 540 | 531 |
| 541 | 532 |
| 542 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { | 533 void FastCodeGenerator::VisitCallRuntime(CallRuntime* expr) { |
| 543 Comment cmnt(masm_, "[ CallRuntime"); | 534 Comment cmnt(masm_, "[ CallRuntime"); |
| 544 ZoneList<Expression*>* args = expr->arguments(); | 535 ZoneList<Expression*>* args = expr->arguments(); |
| 545 Runtime::Function* function = expr->function(); | 536 Runtime::Function* function = expr->function(); |
| 546 | 537 |
| 547 ASSERT(function != NULL); | 538 ASSERT(function != NULL); |
| 548 | 539 |
| 549 // Push the arguments ("left-to-right"). | 540 // Push the arguments ("left-to-right"). |
| 550 int arg_count = args->length(); | 541 int arg_count = args->length(); |
| 551 for (int i = 0; i < arg_count; i++) { | 542 for (int i = 0; i < arg_count; i++) { |
| 552 Visit(args->at(i)); | 543 Visit(args->at(i)); |
| 553 ASSERT(!args->at(i)->location().is_nowhere()); | 544 ASSERT(args->at(i)->location().is_temporary()); |
| 554 if (args->at(i)->location().is_constant()) { | |
| 555 ASSERT(args->at(i)->AsLiteral() != NULL); | |
| 556 __ mov(r0, Operand(args->at(i)->AsLiteral()->handle())); | |
| 557 __ push(r0); | |
| 558 } else { | |
| 559 ASSERT(args->at(i)->location().is_temporary()); | |
| 560 // If location is temporary, it is already on the stack, | |
| 561 // so nothing to do here. | |
| 562 } | |
| 563 } | 545 } |
| 564 | 546 |
| 565 __ CallRuntime(function, arg_count); | 547 __ CallRuntime(function, arg_count); |
| 566 if (expr->location().is_temporary()) { | 548 if (expr->location().is_temporary()) { |
| 567 __ push(r0); | 549 __ push(r0); |
| 568 } else { | 550 } else { |
| 569 ASSERT(expr->location().is_nowhere()); | 551 ASSERT(expr->location().is_nowhere()); |
| 570 } | 552 } |
| 571 } | 553 } |
| 572 | 554 |
| 573 | 555 |
| 574 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { | 556 void FastCodeGenerator::VisitBinaryOperation(BinaryOperation* expr) { |
| 575 // Compile a short-circuited boolean or operation in a non-test | 557 // Compile a short-circuited boolean or operation in a non-test |
| 576 // context. | 558 // context. |
| 577 ASSERT(expr->op() == Token::OR); | 559 ASSERT(expr->op() == Token::OR); |
| 578 // Compile (e0 || e1) as if it were | 560 // Compile (e0 || e1) as if it were |
| 579 // (let (temp = e0) temp ? temp : e1). | 561 // (let (temp = e0) temp ? temp : e1). |
| 580 | 562 |
| 581 Label done; | 563 Label done; |
| 582 Location destination = expr->location(); | 564 Location destination = expr->location(); |
| 583 ASSERT(!destination.is_constant()); | 565 Expression* left = expr->left(); |
| 566 Expression* right = expr->right(); | |
| 584 | 567 |
| 585 Expression* left = expr->left(); | |
| 586 Location left_source = left->location(); | |
| 587 ASSERT(!left_source.is_nowhere()); | |
| 588 | |
| 589 Expression* right = expr->right(); | |
| 590 Location right_source = right->location(); | |
| 591 ASSERT(!right_source.is_nowhere()); | |
| 592 | |
| 593 Visit(left); | |
| 594 // Call the runtime to find the boolean value of the left-hand | 568 // Call the runtime to find the boolean value of the left-hand |
| 595 // subexpression. Duplicate the value if it may be needed as the final | 569 // subexpression. Duplicate the value if it may be needed as the final |
| 596 // result. | 570 // result. |
| 597 if (left_source.is_temporary()) { | 571 if (left->AsLiteral() != NULL) { |
| 572 __ mov(r0, Operand(left->AsLiteral()->handle())); | |
| 573 __ push(r0); | |
| 574 if (destination.is_temporary()) __ push(r0); | |
|
fschneider
2009/10/26 17:57:20
May want to add an assert here to be consistent wi
| |
| 575 } else { | |
| 576 Visit(left); | |
| 577 ASSERT(left->location().is_temporary()); | |
| 598 if (destination.is_temporary()) { | 578 if (destination.is_temporary()) { |
| 599 __ ldr(r0, MemOperand(sp)); | 579 __ ldr(r0, MemOperand(sp)); |
| 600 __ push(r0); | 580 __ push(r0); |
| 601 } | 581 } |
|
fschneider
2009/10/26 17:57:20
Add an assert:
else {
ASSERT(destination.is_now
| |
| 602 } else { | |
| 603 ASSERT(left->AsLiteral() != NULL); | |
| 604 __ mov(r0, Operand(left->AsLiteral()->handle())); | |
| 605 __ push(r0); | |
| 606 if (destination.is_temporary()) __ push(r0); | |
| 607 } | 582 } |
| 608 // The left-hand value is in on top of the stack. It is duplicated on the | 583 // The left-hand value is in on top of the stack. It is duplicated on the |
| 609 // stack iff the destination location is temporary. | 584 // stack iff the destination location is temporary. |
| 610 __ CallRuntime(Runtime::kToBool, 1); | 585 __ CallRuntime(Runtime::kToBool, 1); |
| 611 __ LoadRoot(ip, Heap::kTrueValueRootIndex); | 586 __ LoadRoot(ip, Heap::kTrueValueRootIndex); |
| 612 __ cmp(r0, ip); | 587 __ cmp(r0, ip); |
| 613 __ b(eq, &done); | 588 __ b(eq, &done); |
| 614 | 589 |
| 615 // Discard the left-hand value if present on the stack. | 590 // Discard the left-hand value if present on the stack. |
| 616 if (destination.is_temporary()) __ pop(); | 591 if (destination.is_temporary()) __ pop(); |
| 617 Visit(right); | |
| 618 | |
| 619 // Save or discard the right-hand value as needed. | 592 // Save or discard the right-hand value as needed. |
| 620 if (destination.is_temporary() && right_source.is_constant()) { | 593 if (right->AsLiteral() != NULL) { |
| 621 ASSERT(right->AsLiteral() != NULL); | 594 if (destination.is_temporary()) { |
| 622 __ mov(ip, Operand(right->AsLiteral()->handle())); | 595 __ mov(ip, Operand(right->AsLiteral()->handle())); |
| 623 __ push(ip); | 596 __ push(ip); |
| 624 } else if (destination.is_nowhere() && right_source.is_temporary()) { | 597 } else { |
| 625 __ pop(); | 598 ASSERT(destination.is_nowhere()); |
| 599 } | |
| 600 } else { | |
| 601 Visit(right); | |
| 602 ASSERT(right->location().is_temporary()); | |
| 603 if (destination.is_nowhere()) { | |
| 604 __ pop(); | |
| 605 } else { | |
| 606 ASSERT(destination.is_temporary()); | |
| 607 } | |
| 626 } | 608 } |
| 627 | 609 |
| 628 __ bind(&done); | 610 __ bind(&done); |
| 629 } | 611 } |
| 630 | 612 |
| 631 } } // namespace v8::internal | 613 } } // namespace v8::internal |
| OLD | NEW |