| 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 <iostream> // NOLINT(readability/streams) | 8 #include <iostream> // NOLINT(readability/streams) |
| 9 #include <sstream> |
| 9 | 10 |
| 10 #include "src/v8.h" | 11 #include "src/v8.h" |
| 11 | 12 |
| 12 #include "src/ast.h" | 13 #include "src/ast.h" |
| 13 #include "src/base/platform/platform.h" | 14 #include "src/base/platform/platform.h" |
| 14 #include "src/base/sys-info.h" | 15 #include "src/base/sys-info.h" |
| 15 #include "src/base/utils/random-number-generator.h" | 16 #include "src/base/utils/random-number-generator.h" |
| 16 #include "src/basic-block-profiler.h" | 17 #include "src/basic-block-profiler.h" |
| 17 #include "src/bootstrapper.h" | 18 #include "src/bootstrapper.h" |
| 18 #include "src/codegen.h" | 19 #include "src/codegen.h" |
| (...skipping 1929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1948 clear_scheduled_exception(); | 1949 clear_scheduled_exception(); |
| 1949 | 1950 |
| 1950 // Deserializing may put strange things in the root array's copy of the | 1951 // Deserializing may put strange things in the root array's copy of the |
| 1951 // stack guard. | 1952 // stack guard. |
| 1952 heap_.SetStackLimits(); | 1953 heap_.SetStackLimits(); |
| 1953 | 1954 |
| 1954 // Quiet the heap NaN if needed on target platform. | 1955 // Quiet the heap NaN if needed on target platform. |
| 1955 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); | 1956 if (!create_heap_objects) Assembler::QuietNaN(heap_.nan_value()); |
| 1956 | 1957 |
| 1957 if (FLAG_trace_turbo) { | 1958 if (FLAG_trace_turbo) { |
| 1958 // Erase the file. | 1959 // Create an empty file. |
| 1959 char buffer[512]; | 1960 std::ofstream(GetTurboCfgFileName().c_str(), std::ios_base::trunc); |
| 1960 Vector<char> filename(buffer, sizeof(buffer)); | |
| 1961 GetTurboCfgFileName(filename); | |
| 1962 std::ofstream turbo_cfg_stream(filename.start(), | |
| 1963 std::fstream::out | std::fstream::trunc); | |
| 1964 } | 1961 } |
| 1965 | 1962 |
| 1966 // If we are deserializing, log non-function code objects and compiled | 1963 // If we are deserializing, log non-function code objects and compiled |
| 1967 // functions found in the snapshot. | 1964 // functions found in the snapshot. |
| 1968 if (!create_heap_objects && | 1965 if (!create_heap_objects && |
| 1969 (FLAG_log_code || | 1966 (FLAG_log_code || |
| 1970 FLAG_ll_prof || | 1967 FLAG_ll_prof || |
| 1971 FLAG_perf_jit_prof || | 1968 FLAG_perf_jit_prof || |
| 1972 FLAG_perf_basic_prof || | 1969 FLAG_perf_basic_prof || |
| 1973 logger_->is_logging_code_events())) { | 1970 logger_->is_logging_code_events())) { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2370 | 2367 |
| 2371 | 2368 |
| 2372 BasicBlockProfiler* Isolate::GetOrCreateBasicBlockProfiler() { | 2369 BasicBlockProfiler* Isolate::GetOrCreateBasicBlockProfiler() { |
| 2373 if (basic_block_profiler_ == NULL) { | 2370 if (basic_block_profiler_ == NULL) { |
| 2374 basic_block_profiler_ = new BasicBlockProfiler(); | 2371 basic_block_profiler_ = new BasicBlockProfiler(); |
| 2375 } | 2372 } |
| 2376 return basic_block_profiler_; | 2373 return basic_block_profiler_; |
| 2377 } | 2374 } |
| 2378 | 2375 |
| 2379 | 2376 |
| 2380 void Isolate::GetTurboCfgFileName(Vector<char> filename) { | 2377 std::string Isolate::GetTurboCfgFileName() { |
| 2381 if (FLAG_trace_turbo_cfg_file == NULL) { | 2378 if (FLAG_trace_turbo_cfg_file == NULL) { |
| 2382 SNPrintF(filename, "turbo-%d-%d.cfg", base::OS::GetCurrentProcessId(), | 2379 std::ostringstream os; |
| 2383 id()); | 2380 os << "turbo-" << base::OS::GetCurrentProcessId() << "-" << id() << ".cfg"; |
| 2381 return os.str(); |
| 2384 } else { | 2382 } else { |
| 2385 StrNCpy(filename, FLAG_trace_turbo_cfg_file, filename.length()); | 2383 return FLAG_trace_turbo_cfg_file; |
| 2386 } | 2384 } |
| 2387 } | 2385 } |
| 2388 | 2386 |
| 2389 | 2387 |
| 2390 bool StackLimitCheck::JsHasOverflowed() const { | 2388 bool StackLimitCheck::JsHasOverflowed() const { |
| 2391 StackGuard* stack_guard = isolate_->stack_guard(); | 2389 StackGuard* stack_guard = isolate_->stack_guard(); |
| 2392 #ifdef USE_SIMULATOR | 2390 #ifdef USE_SIMULATOR |
| 2393 // The simulator uses a separate JS stack. | 2391 // The simulator uses a separate JS stack. |
| 2394 Address jssp_address = Simulator::current(isolate_)->get_sp(); | 2392 Address jssp_address = Simulator::current(isolate_)->get_sp(); |
| 2395 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); | 2393 uintptr_t jssp = reinterpret_cast<uintptr_t>(jssp_address); |
| 2396 if (jssp < stack_guard->real_jslimit()) return true; | 2394 if (jssp < stack_guard->real_jslimit()) return true; |
| 2397 #endif // USE_SIMULATOR | 2395 #endif // USE_SIMULATOR |
| 2398 return GetCurrentStackPosition() < stack_guard->real_climit(); | 2396 return GetCurrentStackPosition() < stack_guard->real_climit(); |
| 2399 } | 2397 } |
| 2400 | 2398 |
| 2401 | 2399 |
| 2402 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { | 2400 bool PostponeInterruptsScope::Intercept(StackGuard::InterruptFlag flag) { |
| 2403 // First check whether the previous scope intercepts. | 2401 // First check whether the previous scope intercepts. |
| 2404 if (prev_ && prev_->Intercept(flag)) return true; | 2402 if (prev_ && prev_->Intercept(flag)) return true; |
| 2405 // Then check whether this scope intercepts. | 2403 // Then check whether this scope intercepts. |
| 2406 if ((flag & intercept_mask_)) { | 2404 if ((flag & intercept_mask_)) { |
| 2407 intercepted_flags_ |= flag; | 2405 intercepted_flags_ |= flag; |
| 2408 return true; | 2406 return true; |
| 2409 } | 2407 } |
| 2410 return false; | 2408 return false; |
| 2411 } | 2409 } |
| 2412 | 2410 |
| 2413 } } // namespace v8::internal | 2411 } } // namespace v8::internal |
| OLD | NEW |