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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 template <> | 250 template <> |
| 251 MemOperand FastCodeGenerator::CreateSlotOperand<MemOperand>( | 251 MemOperand FastCodeGenerator::CreateSlotOperand<MemOperand>( |
| 252 Slot* source, | 252 Slot* source, |
| 253 Register scratch) { | 253 Register scratch) { |
| 254 switch (source->type()) { | 254 switch (source->type()) { |
| 255 case Slot::PARAMETER: | 255 case Slot::PARAMETER: // Fall through. |
|
Lasse Reichstein
2010/01/05 06:16:57
I think two cases immediately after each other is
Lasse Reichstein
2010/01/05 06:17:52
"Idiom", even.
| |
| 256 case Slot::LOCAL: | 256 case Slot::LOCAL: |
| 257 return MemOperand(fp, SlotOffset(source)); | 257 return MemOperand(fp, SlotOffset(source)); |
| 258 case Slot::CONTEXT: { | 258 case Slot::CONTEXT: { |
| 259 int context_chain_length = | 259 int context_chain_length = |
| 260 function_->scope()->ContextChainLength(source->var()->scope()); | 260 function_->scope()->ContextChainLength(source->var()->scope()); |
| 261 __ LoadContext(scratch, context_chain_length); | 261 __ LoadContext(scratch, context_chain_length); |
| 262 return CodeGenerator::ContextOperand(scratch, source->index()); | 262 return CodeGenerator::ContextOperand(scratch, source->index()); |
| 263 break; | |
| 264 } | 263 } |
| 265 case Slot::LOOKUP: | 264 case Slot::LOOKUP: |
| 266 UNIMPLEMENTED(); | 265 UNIMPLEMENTED(); |
| 267 // Fall-through. | |
| 268 default: | |
| 269 UNREACHABLE(); | |
| 270 return MemOperand(r0, 0); // Dead code to make the compiler happy. | |
| 271 } | 266 } |
| 267 UNREACHABLE(); | |
| 268 return MemOperand(r0, 0); | |
| 272 } | 269 } |
| 273 | 270 |
| 274 | 271 |
| 275 void FastCodeGenerator::Move(Register dst, Slot* source) { | 272 void FastCodeGenerator::Move(Register dst, Slot* source) { |
| 276 // Use dst as scratch. | 273 // Use dst as scratch. |
| 277 MemOperand location = CreateSlotOperand<MemOperand>(source, dst); | 274 MemOperand location = CreateSlotOperand<MemOperand>(source, dst); |
| 278 __ ldr(dst, location); | 275 __ ldr(dst, location); |
| 279 } | 276 } |
| 280 | 277 |
| 281 | 278 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 function_->scope()->ContextChainLength(dst->var()->scope()); | 327 function_->scope()->ContextChainLength(dst->var()->scope()); |
| 331 __ LoadContext(scratch1, context_chain_length); | 328 __ LoadContext(scratch1, context_chain_length); |
| 332 int index = Context::SlotOffset(dst->index()); | 329 int index = Context::SlotOffset(dst->index()); |
| 333 __ mov(scratch2, Operand(index)); | 330 __ mov(scratch2, Operand(index)); |
| 334 __ str(src, MemOperand(scratch1, index)); | 331 __ str(src, MemOperand(scratch1, index)); |
| 335 __ RecordWrite(scratch1, scratch2, src); | 332 __ RecordWrite(scratch1, scratch2, src); |
| 336 break; | 333 break; |
| 337 } | 334 } |
| 338 case Slot::LOOKUP: | 335 case Slot::LOOKUP: |
| 339 UNIMPLEMENTED(); | 336 UNIMPLEMENTED(); |
| 340 default: | |
| 341 UNREACHABLE(); | |
| 342 } | 337 } |
| 343 } | 338 } |
| 344 | 339 |
| 345 | 340 |
| 346 | 341 |
| 347 void FastCodeGenerator::DropAndMove(Expression::Context context, | 342 void FastCodeGenerator::DropAndMove(Expression::Context context, |
| 348 Register source, | 343 Register source, |
| 349 int drop_count) { | 344 int drop_count) { |
| 350 ASSERT(drop_count > 0); | 345 ASSERT(drop_count > 0); |
| 351 switch (context) { | 346 switch (context) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 556 __ ldr(ip, CodeGenerator::GlobalObject()); | 551 __ ldr(ip, CodeGenerator::GlobalObject()); |
| 557 __ push(ip); | 552 __ push(ip); |
| 558 __ mov(r2, Operand(var->name())); | 553 __ mov(r2, Operand(var->name())); |
| 559 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); | 554 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Initialize)); |
| 560 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); | 555 __ Call(ic, RelocInfo::CODE_TARGET_CONTEXT); |
| 561 DropAndMove(context, r0); | 556 DropAndMove(context, r0); |
| 562 } else if (rewrite->AsSlot() != NULL) { | 557 } else if (rewrite->AsSlot() != NULL) { |
| 563 Slot* slot = rewrite->AsSlot(); | 558 Slot* slot = rewrite->AsSlot(); |
| 564 if (FLAG_debug_code) { | 559 if (FLAG_debug_code) { |
| 565 switch (slot->type()) { | 560 switch (slot->type()) { |
| 566 case Slot::LOCAL: | 561 case Slot::LOCAL: // Fall through. |
| 567 case Slot::PARAMETER: { | 562 case Slot::PARAMETER: { |
| 568 Comment cmnt(masm_, "Stack slot"); | 563 Comment cmnt(masm_, "Stack slot"); |
| 569 break; | 564 break; |
| 570 } | 565 } |
| 571 case Slot::CONTEXT: { | 566 case Slot::CONTEXT: { |
| 572 Comment cmnt(masm_, "Context slot"); | 567 Comment cmnt(masm_, "Context slot"); |
| 573 break; | 568 break; |
| 574 } | 569 } |
| 575 case Slot::LOOKUP: | 570 case Slot::LOOKUP: |
| 576 UNIMPLEMENTED(); | 571 UNIMPLEMENTED(); |
| 577 break; | 572 break; |
| 578 default: | |
| 579 UNREACHABLE(); | |
| 580 } | 573 } |
| 581 } | 574 } |
| 582 Move(context, slot, r0); | 575 Move(context, slot, r0); |
| 583 } else { | 576 } else { |
| 584 // A variable has been rewritten into an explicit access to | 577 // A variable has been rewritten into an explicit access to |
| 585 // an object property. | 578 // an object property. |
| 586 Property* property = rewrite->AsProperty(); | 579 Property* property = rewrite->AsProperty(); |
| 587 ASSERT_NOT_NULL(property); | 580 ASSERT_NOT_NULL(property); |
| 588 | 581 |
| 589 // Currently the only parameter expressions that can occur are | 582 // Currently the only parameter expressions that can occur are |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1731 __ pop(result_register()); | 1724 __ pop(result_register()); |
| 1732 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); | 1725 ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize); |
| 1733 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. | 1726 __ mov(r1, Operand(r1, ASR, 1)); // Un-smi-tag value. |
| 1734 __ add(pc, r1, Operand(masm_->CodeObject())); | 1727 __ add(pc, r1, Operand(masm_->CodeObject())); |
| 1735 } | 1728 } |
| 1736 | 1729 |
| 1737 | 1730 |
| 1738 #undef __ | 1731 #undef __ |
| 1739 | 1732 |
| 1740 } } // namespace v8::internal | 1733 } } // namespace v8::internal |
| OLD | NEW |