OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 if (isolate()->IsDebuggerActive()) { | 339 if (isolate()->IsDebuggerActive()) { |
340 // Detect debug break requests as soon as possible. | 340 // Detect debug break requests as soon as possible. |
341 reset_value = FLAG_interrupt_budget >> 4; | 341 reset_value = FLAG_interrupt_budget >> 4; |
342 } | 342 } |
343 __ li(a2, Operand(profiling_counter_)); | 343 __ li(a2, Operand(profiling_counter_)); |
344 __ li(a3, Operand(Smi::FromInt(reset_value))); | 344 __ li(a3, Operand(Smi::FromInt(reset_value))); |
345 __ sw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset)); | 345 __ sw(a3, FieldMemOperand(a2, JSGlobalPropertyCell::kValueOffset)); |
346 } | 346 } |
347 | 347 |
348 | 348 |
349 void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt, | 349 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, |
350 Label* back_edge_target) { | 350 Label* back_edge_target) { |
351 // The generated code is used in Deoptimizer::PatchStackCheckCodeAt so we need | 351 // The generated code is used in Deoptimizer::PatchStackCheckCodeAt so we need |
352 // to make sure it is constant. Branch may emit a skip-or-jump sequence | 352 // to make sure it is constant. Branch may emit a skip-or-jump sequence |
353 // instead of the normal Branch. It seems that the "skip" part of that | 353 // instead of the normal Branch. It seems that the "skip" part of that |
354 // sequence is about as long as this Branch would be so it is safe to ignore | 354 // sequence is about as long as this Branch would be so it is safe to ignore |
355 // that. | 355 // that. |
356 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); | 356 Assembler::BlockTrampolinePoolScope block_trampoline_pool(masm_); |
357 Comment cmnt(masm_, "[ Stack check"); | 357 Comment cmnt(masm_, "[ Back edge bookkeeping"); |
358 Label ok; | 358 Label ok; |
359 if (FLAG_count_based_interrupts) { | 359 int weight = 1; |
360 int weight = 1; | 360 if (FLAG_weighted_back_edges) { |
361 if (FLAG_weighted_back_edges) { | 361 ASSERT(back_edge_target->is_bound()); |
362 ASSERT(back_edge_target->is_bound()); | 362 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); |
363 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); | 363 weight = Min(kMaxBackEdgeWeight, |
364 weight = Min(kMaxBackEdgeWeight, | 364 Max(1, distance / kBackEdgeDistanceUnit)); |
365 Max(1, distance / kBackEdgeDistanceUnit)); | |
366 } | |
367 EmitProfilingCounterDecrement(weight); | |
368 __ slt(at, a3, zero_reg); | |
369 __ beq(at, zero_reg, &ok); | |
370 // CallStub will emit a li t9 first, so it is safe to use the delay slot. | |
371 InterruptStub stub; | |
372 __ CallStub(&stub); | |
373 } else { | |
374 __ LoadRoot(t0, Heap::kStackLimitRootIndex); | |
375 __ sltu(at, sp, t0); | |
376 __ beq(at, zero_reg, &ok); | |
377 // CallStub will emit a li t9 first, so it is safe to use the delay slot. | |
378 StackCheckStub stub; | |
379 __ CallStub(&stub); | |
380 } | 365 } |
| 366 EmitProfilingCounterDecrement(weight); |
| 367 __ slt(at, a3, zero_reg); |
| 368 __ beq(at, zero_reg, &ok); |
| 369 // CallStub will emit a li t9 first, so it is safe to use the delay slot. |
| 370 InterruptStub stub; |
| 371 __ CallStub(&stub); |
381 // Record a mapping of this PC offset to the OSR id. This is used to find | 372 // Record a mapping of this PC offset to the OSR id. This is used to find |
382 // the AST id from the unoptimized code in order to use it as a key into | 373 // the AST id from the unoptimized code in order to use it as a key into |
383 // the deoptimization input data found in the optimized code. | 374 // the deoptimization input data found in the optimized code. |
384 RecordStackCheck(stmt->OsrEntryId()); | 375 RecordBackEdge(stmt->OsrEntryId()); |
385 if (FLAG_count_based_interrupts) { | 376 EmitProfilingCounterReset(); |
386 EmitProfilingCounterReset(); | |
387 } | |
388 | 377 |
389 __ bind(&ok); | 378 __ bind(&ok); |
390 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); | 379 PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS); |
391 // Record a mapping of the OSR id to this PC. This is used if the OSR | 380 // Record a mapping of the OSR id to this PC. This is used if the OSR |
392 // entry becomes the target of a bailout. We don't expect it to be, but | 381 // entry becomes the target of a bailout. We don't expect it to be, but |
393 // we want it to work if it is. | 382 // we want it to work if it is. |
394 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); | 383 PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS); |
395 } | 384 } |
396 | 385 |
397 | 386 |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1252 // Generate code for the body of the loop. | 1241 // Generate code for the body of the loop. |
1253 Visit(stmt->body()); | 1242 Visit(stmt->body()); |
1254 | 1243 |
1255 // Generate code for the going to the next element by incrementing | 1244 // Generate code for the going to the next element by incrementing |
1256 // the index (smi) stored on top of the stack. | 1245 // the index (smi) stored on top of the stack. |
1257 __ bind(loop_statement.continue_label()); | 1246 __ bind(loop_statement.continue_label()); |
1258 __ pop(a0); | 1247 __ pop(a0); |
1259 __ Addu(a0, a0, Operand(Smi::FromInt(1))); | 1248 __ Addu(a0, a0, Operand(Smi::FromInt(1))); |
1260 __ push(a0); | 1249 __ push(a0); |
1261 | 1250 |
1262 EmitStackCheck(stmt, &loop); | 1251 EmitBackEdgeBookkeeping(stmt, &loop); |
1263 __ Branch(&loop); | 1252 __ Branch(&loop); |
1264 | 1253 |
1265 // Remove the pointers stored on the stack. | 1254 // Remove the pointers stored on the stack. |
1266 __ bind(loop_statement.break_label()); | 1255 __ bind(loop_statement.break_label()); |
1267 __ Drop(5); | 1256 __ Drop(5); |
1268 | 1257 |
1269 // Exit and decrement the loop depth. | 1258 // Exit and decrement the loop depth. |
1270 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); | 1259 PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS); |
1271 __ bind(&exit); | 1260 __ bind(&exit); |
1272 decrement_loop_depth(); | 1261 decrement_loop_depth(); |
(...skipping 3282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4555 *context_length = 0; | 4544 *context_length = 0; |
4556 return previous_; | 4545 return previous_; |
4557 } | 4546 } |
4558 | 4547 |
4559 | 4548 |
4560 #undef __ | 4549 #undef __ |
4561 | 4550 |
4562 } } // namespace v8::internal | 4551 } } // namespace v8::internal |
4563 | 4552 |
4564 #endif // V8_TARGET_ARCH_MIPS | 4553 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |