OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, | 385 void FullCodeGenerator::EmitBackEdgeBookkeeping(IterationStatement* stmt, |
386 Label* back_edge_target) { | 386 Label* back_edge_target) { |
387 ASSERT(jssp.Is(__ StackPointer())); | 387 ASSERT(jssp.Is(__ StackPointer())); |
388 Comment cmnt(masm_, "[ Back edge bookkeeping"); | 388 Comment cmnt(masm_, "[ Back edge bookkeeping"); |
389 // Block literal pools whilst emitting back edge code. | 389 // Block literal pools whilst emitting back edge code. |
390 Assembler::BlockPoolsScope block_const_pool(masm_); | 390 Assembler::BlockPoolsScope block_const_pool(masm_); |
391 Label ok; | 391 Label ok; |
392 | 392 |
393 ASSERT(back_edge_target->is_bound()); | 393 ASSERT(back_edge_target->is_bound()); |
394 int distance = masm_->SizeOfCodeGeneratedSince(back_edge_target); | 394 // We want to do a round rather than a floor of distance/kCodeSizeMultiplier |
| 395 // to reduce the absolute error due to the integer division. To do that, |
| 396 // we add kCodeSizeMultiplier/2 to the distance (equivalent to adding 0.5 to |
| 397 // the result). |
| 398 int distance = |
| 399 masm_->SizeOfCodeGeneratedSince(back_edge_target) + kCodeSizeMultiplier / 2; |
395 int weight = Min(kMaxBackEdgeWeight, | 400 int weight = Min(kMaxBackEdgeWeight, |
396 Max(1, distance / kCodeSizeMultiplier)); | 401 Max(1, distance / kCodeSizeMultiplier)); |
397 EmitProfilingCounterDecrement(weight); | 402 EmitProfilingCounterDecrement(weight); |
398 __ B(pl, &ok); | 403 __ B(pl, &ok); |
399 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); | 404 __ Call(isolate()->builtins()->InterruptCheck(), RelocInfo::CODE_TARGET); |
400 | 405 |
401 // Record a mapping of this PC offset to the OSR id. This is used to find | 406 // Record a mapping of this PC offset to the OSR id. This is used to find |
402 // the AST id from the unoptimized code in order to use it as a key into | 407 // the AST id from the unoptimized code in order to use it as a key into |
403 // the deoptimization input data found in the optimized code. | 408 // the deoptimization input data found in the optimized code. |
404 RecordBackEdge(stmt->OsrEntryId()); | 409 RecordBackEdge(stmt->OsrEntryId()); |
(...skipping 22 matching lines...) Expand all Loading... |
427 // Runtime::TraceExit returns its parameter in x0. | 432 // Runtime::TraceExit returns its parameter in x0. |
428 __ Push(result_register()); | 433 __ Push(result_register()); |
429 __ CallRuntime(Runtime::kTraceExit, 1); | 434 __ CallRuntime(Runtime::kTraceExit, 1); |
430 ASSERT(x0.Is(result_register())); | 435 ASSERT(x0.Is(result_register())); |
431 } | 436 } |
432 // Pretend that the exit is a backwards jump to the entry. | 437 // Pretend that the exit is a backwards jump to the entry. |
433 int weight = 1; | 438 int weight = 1; |
434 if (info_->ShouldSelfOptimize()) { | 439 if (info_->ShouldSelfOptimize()) { |
435 weight = FLAG_interrupt_budget / FLAG_self_opt_count; | 440 weight = FLAG_interrupt_budget / FLAG_self_opt_count; |
436 } else { | 441 } else { |
437 int distance = masm_->pc_offset(); | 442 int distance = masm_->pc_offset() + kCodeSizeMultiplier / 2; |
438 weight = Min(kMaxBackEdgeWeight, | 443 weight = Min(kMaxBackEdgeWeight, |
439 Max(1, distance / kCodeSizeMultiplier)); | 444 Max(1, distance / kCodeSizeMultiplier)); |
440 } | 445 } |
441 EmitProfilingCounterDecrement(weight); | 446 EmitProfilingCounterDecrement(weight); |
442 Label ok; | 447 Label ok; |
443 __ B(pl, &ok); | 448 __ B(pl, &ok); |
444 __ Push(x0); | 449 __ Push(x0); |
445 __ Call(isolate()->builtins()->InterruptCheck(), | 450 __ Call(isolate()->builtins()->InterruptCheck(), |
446 RelocInfo::CODE_TARGET); | 451 RelocInfo::CODE_TARGET); |
447 __ Pop(x0); | 452 __ Pop(x0); |
(...skipping 4552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5000 return previous_; | 5005 return previous_; |
5001 } | 5006 } |
5002 | 5007 |
5003 | 5008 |
5004 #undef __ | 5009 #undef __ |
5005 | 5010 |
5006 | 5011 |
5007 } } // namespace v8::internal | 5012 } } // namespace v8::internal |
5008 | 5013 |
5009 #endif // V8_TARGET_ARCH_ARM64 | 5014 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |