| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 if (should_trace) { | 292 if (should_trace) { |
| 293 frame_->CallRuntime(Runtime::kDebugTrace, 0); | 293 frame_->CallRuntime(Runtime::kDebugTrace, 0); |
| 294 // Ignore the return value. | 294 // Ignore the return value. |
| 295 } | 295 } |
| 296 #endif | 296 #endif |
| 297 VisitStatementsAndSpill(body); | 297 VisitStatementsAndSpill(body); |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 // Generate the return sequence if necessary. | 301 // Generate the return sequence if necessary. |
| 302 if (frame_ != NULL || function_return_.is_linked()) { | 302 if (has_valid_frame() || function_return_.is_linked()) { |
| 303 if (!function_return_.is_linked()) { |
| 304 CodeForReturnPosition(fun); |
| 305 } |
| 303 // exit | 306 // exit |
| 304 // r0: result | 307 // r0: result |
| 305 // sp: stack pointer | 308 // sp: stack pointer |
| 306 // fp: frame pointer | 309 // fp: frame pointer |
| 307 // cp: callee's context | 310 // cp: callee's context |
| 308 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); | 311 __ LoadRoot(r0, Heap::kUndefinedValueRootIndex); |
| 309 | 312 |
| 310 function_return_.Bind(); | 313 function_return_.Bind(); |
| 311 if (FLAG_trace) { | 314 if (FLAG_trace) { |
| 312 // Push the return value on the stack as the parameter. | 315 // Push the return value on the stack as the parameter. |
| 313 // Runtime::TraceExit returns the parameter as it is. | 316 // Runtime::TraceExit returns the parameter as it is. |
| 314 frame_->EmitPush(r0); | 317 frame_->EmitPush(r0); |
| 315 frame_->CallRuntime(Runtime::kTraceExit, 1); | 318 frame_->CallRuntime(Runtime::kTraceExit, 1); |
| 316 } | 319 } |
| 317 | 320 |
| 321 // Add a label for checking the size of the code used for returning. |
| 322 Label check_exit_codesize; |
| 323 masm_->bind(&check_exit_codesize); |
| 324 |
| 318 // Tear down the frame which will restore the caller's frame pointer and | 325 // Tear down the frame which will restore the caller's frame pointer and |
| 319 // the link register. | 326 // the link register. |
| 320 frame_->Exit(); | 327 frame_->Exit(); |
| 321 | 328 |
| 322 __ add(sp, sp, Operand((scope_->num_parameters() + 1) * kPointerSize)); | 329 // Here we use masm_-> instead of the __ macro to avoid the code coverage |
| 323 __ Jump(lr); | 330 // tool from instrumenting as we rely on the code size here. |
| 331 masm_->add(sp, sp, Operand((scope_->num_parameters() + 1) * kPointerSize)); |
| 332 masm_->Jump(lr); |
| 333 |
| 334 // Check that the size of the code used for returning matches what is |
| 335 // expected by the debugger. |
| 336 ASSERT_EQ(kJSReturnSequenceLength, |
| 337 masm_->InstructionsGeneratedSince(&check_exit_codesize)); |
| 338 |
| 324 } | 339 } |
| 325 | 340 |
| 326 // Code generation state must be reset. | 341 // Code generation state must be reset. |
| 327 ASSERT(!has_cc()); | 342 ASSERT(!has_cc()); |
| 328 ASSERT(state_ == NULL); | 343 ASSERT(state_ == NULL); |
| 329 ASSERT(!function_return_is_shadowed_); | 344 ASSERT(!function_return_is_shadowed_); |
| 330 function_return_.Unuse(); | 345 function_return_.Unuse(); |
| 331 DeleteFrame(); | 346 DeleteFrame(); |
| 332 | 347 |
| 333 // Process any deferred code using the register allocator. | 348 // Process any deferred code using the register allocator. |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 target->Branch(cc); | 1119 target->Branch(cc); |
| 1105 cc_reg_ = al; | 1120 cc_reg_ = al; |
| 1106 } | 1121 } |
| 1107 | 1122 |
| 1108 | 1123 |
| 1109 void CodeGenerator::CheckStack() { | 1124 void CodeGenerator::CheckStack() { |
| 1110 VirtualFrame::SpilledScope spilled_scope; | 1125 VirtualFrame::SpilledScope spilled_scope; |
| 1111 if (FLAG_check_stack) { | 1126 if (FLAG_check_stack) { |
| 1112 Comment cmnt(masm_, "[ check stack"); | 1127 Comment cmnt(masm_, "[ check stack"); |
| 1113 __ LoadRoot(ip, Heap::kStackLimitRootIndex); | 1128 __ LoadRoot(ip, Heap::kStackLimitRootIndex); |
| 1114 // Put the lr setup instruction in the delay slot. The 'sizeof(Instr)' is | 1129 // Put the lr setup instruction in the delay slot. kInstrSize is added to |
| 1115 // added to the implicit 8 byte offset that always applies to operations | 1130 // the implicit 8 byte offset that always applies to operations with pc and |
| 1116 // with pc and gives a return address 12 bytes down. | 1131 // gives a return address 12 bytes down. |
| 1117 masm_->add(lr, pc, Operand(sizeof(Instr))); | 1132 masm_->add(lr, pc, Operand(Assembler::kInstrSize)); |
| 1118 masm_->cmp(sp, Operand(ip)); | 1133 masm_->cmp(sp, Operand(ip)); |
| 1119 StackCheckStub stub; | 1134 StackCheckStub stub; |
| 1120 // Call the stub if lower. | 1135 // Call the stub if lower. |
| 1121 masm_->mov(pc, | 1136 masm_->mov(pc, |
| 1122 Operand(reinterpret_cast<intptr_t>(stub.GetCode().location()), | 1137 Operand(reinterpret_cast<intptr_t>(stub.GetCode().location()), |
| 1123 RelocInfo::CODE_TARGET), | 1138 RelocInfo::CODE_TARGET), |
| 1124 LeaveCC, | 1139 LeaveCC, |
| 1125 lo); | 1140 lo); |
| 1126 } | 1141 } |
| 1127 } | 1142 } |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 Comment cmnt(masm_, "[ BreakStatement"); | 1388 Comment cmnt(masm_, "[ BreakStatement"); |
| 1374 CodeForStatementPosition(node); | 1389 CodeForStatementPosition(node); |
| 1375 node->target()->break_target()->Jump(); | 1390 node->target()->break_target()->Jump(); |
| 1376 } | 1391 } |
| 1377 | 1392 |
| 1378 | 1393 |
| 1379 void CodeGenerator::VisitReturnStatement(ReturnStatement* node) { | 1394 void CodeGenerator::VisitReturnStatement(ReturnStatement* node) { |
| 1380 VirtualFrame::SpilledScope spilled_scope; | 1395 VirtualFrame::SpilledScope spilled_scope; |
| 1381 Comment cmnt(masm_, "[ ReturnStatement"); | 1396 Comment cmnt(masm_, "[ ReturnStatement"); |
| 1382 | 1397 |
| 1398 CodeForStatementPosition(node); |
| 1399 LoadAndSpill(node->expression()); |
| 1383 if (function_return_is_shadowed_) { | 1400 if (function_return_is_shadowed_) { |
| 1384 CodeForStatementPosition(node); | |
| 1385 LoadAndSpill(node->expression()); | |
| 1386 frame_->EmitPop(r0); | 1401 frame_->EmitPop(r0); |
| 1387 function_return_.Jump(); | 1402 function_return_.Jump(); |
| 1388 } else { | 1403 } else { |
| 1389 // Load the returned value. | |
| 1390 CodeForStatementPosition(node); | |
| 1391 LoadAndSpill(node->expression()); | |
| 1392 | |
| 1393 // Pop the result from the frame and prepare the frame for | 1404 // Pop the result from the frame and prepare the frame for |
| 1394 // returning thus making it easier to merge. | 1405 // returning thus making it easier to merge. |
| 1395 frame_->EmitPop(r0); | 1406 frame_->EmitPop(r0); |
| 1396 frame_->PrepareForReturn(); | 1407 frame_->PrepareForReturn(); |
| 1397 | 1408 |
| 1398 function_return_.Jump(); | 1409 function_return_.Jump(); |
| 1399 } | 1410 } |
| 1400 } | 1411 } |
| 1401 | 1412 |
| 1402 | 1413 |
| (...skipping 4855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6258 int CompareStub::MinorKey() { | 6269 int CompareStub::MinorKey() { |
| 6259 // Encode the two parameters in a unique 16 bit value. | 6270 // Encode the two parameters in a unique 16 bit value. |
| 6260 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); | 6271 ASSERT(static_cast<unsigned>(cc_) >> 28 < (1 << 15)); |
| 6261 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); | 6272 return (static_cast<unsigned>(cc_) >> 27) | (strict_ ? 1 : 0); |
| 6262 } | 6273 } |
| 6263 | 6274 |
| 6264 | 6275 |
| 6265 #undef __ | 6276 #undef __ |
| 6266 | 6277 |
| 6267 } } // namespace v8::internal | 6278 } } // namespace v8::internal |
| OLD | NEW |