| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdlib.h> | 5 #include <stdlib.h> |
| 6 | 6 |
| 7 #include <fstream> // NOLINT(readability/streams) | 7 #include <fstream> // NOLINT(readability/streams) |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 2514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2525 if (FLAG_trace_turbo_cfg_file == NULL) { | 2525 if (FLAG_trace_turbo_cfg_file == NULL) { |
| 2526 std::ostringstream os; | 2526 std::ostringstream os; |
| 2527 os << "turbo-" << base::OS::GetCurrentProcessId() << "-" << id() << ".cfg"; | 2527 os << "turbo-" << base::OS::GetCurrentProcessId() << "-" << id() << ".cfg"; |
| 2528 return os.str(); | 2528 return os.str(); |
| 2529 } else { | 2529 } else { |
| 2530 return FLAG_trace_turbo_cfg_file; | 2530 return FLAG_trace_turbo_cfg_file; |
| 2531 } | 2531 } |
| 2532 } | 2532 } |
| 2533 | 2533 |
| 2534 | 2534 |
| 2535 void Isolate::AddGuardArea(void const* address, size_t const length) { |
| 2536 DCHECK(address != nullptr); |
| 2537 DCHECK(length != 0); |
| 2538 DCHECK((bit_cast<uintptr_t>(address) % base::OS::CommitPageSize()) == 0); |
| 2539 DCHECK((length % base::OS::CommitPageSize()) == 0); |
| 2540 DCHECK(!IsInGuardArea(address)); |
| 2541 base::OS::Guard(const_cast<void*>(address), length); |
| 2542 guard_areas_.push_back( |
| 2543 std::make_pair(address, static_cast<uint8_t const*>(address) + length)); |
| 2544 } |
| 2545 |
| 2546 |
| 2547 void Isolate::RemoveGuardArea(void const* address, size_t const length) { |
| 2548 DCHECK(address != nullptr); |
| 2549 DCHECK(length != 0); |
| 2550 DCHECK((bit_cast<uintptr_t>(address) % base::OS::CommitPageSize()) == 0); |
| 2551 DCHECK((length % base::OS::CommitPageSize()) == 0); |
| 2552 base::OS::Unguard(const_cast<void*>(address), length); |
| 2553 for (auto i = guard_areas_.begin(); ; ++i) { |
| 2554 DCHECK(i != guard_areas_.end()); |
| 2555 if (i->first == address) { |
| 2556 guard_areas_.erase(i); |
| 2557 break; |
| 2558 } |
| 2559 } |
| 2560 } |
| 2561 |
| 2562 |
| 2563 bool Isolate::IsInGuardArea(void const* address) const { |
| 2564 for (auto i = guard_areas_.begin(); i != guard_areas_.end(); ++i) { |
| 2565 if (i->first <= address && address < i->second) { |
| 2566 return true; |
| 2567 } |
| 2568 } |
| 2569 return false; |
| 2570 } |
| 2571 |
| 2572 |
| 2535 bool StackLimitCheck::JsHasOverflowed() const { | 2573 bool StackLimitCheck::JsHasOverflowed() const { |
| 2536 StackGuard* stack_guard = isolate_->stack_guard(); | 2574 StackGuard* stack_guard = isolate_->stack_guard(); |
| 2537 #ifdef USE_SIMULATOR | 2575 #ifdef USE_SIMULATOR |
| 2538 // The simulator uses a separate JS stack. | 2576 // The simulator uses a separate JS stack. |
| 2539 Address jssp_address = Simulator::current(isolate_)->get_sp(); | 2577 Address jssp_address = Simulator::current(isolate_)->get_sp(); |
| 2540 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); | 2578 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); |
| 2541 if (jssp < stack_guard->real_jslimit()) return true; | 2579 if (jssp < stack_guard->real_jslimit()) return true; |
| 2542 #endif // USE_SIMULATOR | 2580 #endif // USE_SIMULATOR |
| 2543 return GetCurrentStackPosition() < stack_guard->real_climit(); | 2581 return GetCurrentStackPosition() < stack_guard->real_climit(); |
| 2544 } | 2582 } |
| 2545 | 2583 |
| 2546 | 2584 |
| 2547 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { | 2585 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { |
| 2548 // First check whether the previous scope intercepts. | 2586 // First check whether the previous scope intercepts. |
| 2549 if (prev_ && prev_->Intercept(flag)) return true; | 2587 if (prev_ && prev_->Intercept(flag)) return true; |
| 2550 // Then check whether this scope intercepts. | 2588 // Then check whether this scope intercepts. |
| 2551 if ((flag & intercept_mask_)) { | 2589 if ((flag & intercept_mask_)) { |
| 2552 intercepted_flags_ |= flag; | 2590 intercepted_flags_ |= flag; |
| 2553 return true; | 2591 return true; |
| 2554 } | 2592 } |
| 2555 return false; | 2593 return false; |
| 2556 } | 2594 } |
| 2557 | 2595 |
| 2558 } } // namespace v8::internal | 2596 } } // namespace v8::internal |
| OLD | NEW |