From a4506cd3f2e6735b07b31e26ed0916eb253ced27 Mon Sep 17 00:00:00 2001 From: "jochen@chromium.org" Date: Mon, 30 Jun 2014 13:25:46 +0000 Subject: [PATCH] Move platform abstraction to base library Also split v8-core independent methods from checks.h to base/logging.h and merge v8checks with the rest of checks. The CPU::FlushICache method is moved to CpuFeatures::FlushICache RoundUp and related methods are moved to base/macros.h Remove all layering violations from src/libplatform BUG=none R=jkummerow@chromium.org LOG=n Review URL: https://codereview.chromium.org/358363002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22092 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- BUILD.gn | 121 ++++++----- src/allocation-tracker.cc | 12 +- src/allocation.cc | 4 +- src/api.cc | 29 +-- src/arm/assembler-arm-inl.h | 6 +- src/arm/assembler-arm.cc | 15 +- src/arm/code-stubs-arm.h | 3 +- src/arm/codegen-arm.cc | 30 +-- src/arm/cpu-arm.cc | 4 +- src/arm/disasm-arm.cc | 2 +- src/arm/macro-assembler-arm.cc | 6 +- src/arm/macro-assembler-arm.h | 2 +- src/arm/regexp-macro-assembler-arm.cc | 2 +- src/arm/simulator-arm.cc | 6 +- src/arm64/assembler-arm64-inl.h | 4 +- src/arm64/assembler-arm64.cc | 9 +- src/arm64/assembler-arm64.h | 3 +- src/arm64/codegen-arm64.cc | 7 +- src/arm64/cpu-arm64.cc | 4 +- src/arm64/disasm-arm64.cc | 2 +- src/arm64/macro-assembler-arm64.cc | 2 +- src/arm64/simulator-arm64.cc | 10 +- src/assembler.cc | 37 ++-- src/assembler.h | 3 + src/assert-scope.h | 8 +- src/base/build_config.h | 4 + src/{ => base}/cpu.cc | 8 +- src/{ => base}/cpu.h | 17 +- src/base/logging.cc | 88 ++++++++ src/base/logging.h | 267 +++++++++++++++++++++++ src/base/macros.h | 82 +++++++ src/{ => base}/platform/condition-variable.cc | 8 +- src/{ => base}/platform/condition-variable.h | 18 +- src/{ => base}/platform/elapsed-timer.h | 16 +- src/{ => base}/platform/mutex.cc | 6 +- src/{ => base}/platform/mutex.h | 23 +- src/{ => base/platform}/platform-cygwin.cc | 8 +- src/{ => base/platform}/platform-freebsd.cc | 8 +- src/{ => base/platform}/platform-linux.cc | 8 +- src/{ => base/platform}/platform-macos.cc | 8 +- src/{ => base/platform}/platform-openbsd.cc | 8 +- src/{ => base/platform}/platform-posix.cc | 16 +- src/{ => base/platform}/platform-qnx.cc | 8 +- src/{ => base/platform}/platform-solaris.cc | 8 +- src/{ => base/platform}/platform-win32.cc | 27 +-- src/{ => base/platform}/platform.h | 18 +- src/{ => base}/platform/semaphore.cc | 10 +- src/{ => base}/platform/semaphore.h | 16 +- src/{ => base}/platform/time.cc | 30 ++- src/{ => base}/platform/time.h | 10 +- src/{ => base}/qnx-math.h | 6 +- src/{ => base}/utils/random-number-generator.cc | 10 +- src/{ => base}/utils/random-number-generator.h | 10 +- src/{ => base}/win32-math.cc | 4 +- src/{ => base}/win32-math.h | 6 +- src/bignum-dtoa.cc | 2 +- src/bootstrapper.cc | 4 +- src/cached-powers.cc | 2 +- src/cached-powers.h | 2 +- src/checks.cc | 75 ------- src/checks.h | 272 +++--------------------- src/code-stubs-hydrogen.cc | 2 +- src/compiler.cc | 4 +- src/compiler.h | 14 +- src/conversions-inl.h | 2 +- src/conversions.h | 2 +- src/counters.cc | 2 +- src/counters.h | 6 +- src/cpu-profiler.cc | 10 +- src/cpu-profiler.h | 12 +- src/d8.cc | 30 +-- src/d8.h | 18 +- src/date.cc | 2 +- src/date.h | 15 +- src/debug.cc | 8 +- src/debug.h | 6 +- src/deoptimizer.cc | 8 +- src/diy-fp.cc | 2 +- src/dtoa.cc | 2 +- src/elements-kind.h | 2 +- src/extensions/free-buffer-extension.cc | 3 +- src/extensions/gc-extension.cc | 3 +- src/fast-dtoa.cc | 2 +- src/fixed-dtoa.cc | 2 +- src/flags.cc | 2 +- src/gdb-jit.cc | 10 +- src/globals.h | 16 +- src/hashmap.h | 2 +- src/heap-inl.h | 2 +- src/heap-snapshot-generator.cc | 14 +- src/heap.cc | 15 +- src/heap.h | 6 +- src/hydrogen-bce.cc | 24 +-- src/hydrogen-gvn.cc | 2 +- src/hydrogen-instructions.cc | 11 +- src/hydrogen-range-analysis.cc | 2 +- src/hydrogen.cc | 12 +- src/hydrogen.h | 22 +- src/ia32/assembler-ia32-inl.h | 26 +-- src/ia32/assembler-ia32.cc | 5 +- src/ia32/code-stubs-ia32.h | 2 +- src/ia32/codegen-ia32.cc | 25 +-- src/ia32/cpu-ia32.cc | 4 +- src/ia32/lithium-codegen-ia32.h | 2 +- src/ia32/macro-assembler-ia32.cc | 10 +- src/ic.cc | 2 +- src/incremental-marking.cc | 10 +- src/incremental-marking.h | 2 +- src/isolate-inl.h | 9 +- src/isolate.cc | 73 +++---- src/isolate.h | 41 ++-- src/json-parser.h | 2 +- src/jsregexp.cc | 4 +- src/libplatform/DEPS | 3 +- src/libplatform/default-platform.cc | 13 +- src/libplatform/default-platform.h | 4 +- src/libplatform/task-queue.cc | 11 +- src/libplatform/task-queue.h | 8 +- src/libplatform/worker-thread.h | 4 +- src/list-inl.h | 3 +- src/list.h | 1 + src/lithium-allocator.cc | 4 +- src/log-utils.cc | 4 +- src/log-utils.h | 4 +- src/log.cc | 53 ++--- src/log.h | 12 +- src/mark-compact.cc | 7 +- src/mark-compact.h | 2 +- src/mips/assembler-mips-inl.h | 4 +- src/mips/assembler-mips.cc | 10 +- src/mips/code-stubs-mips.h | 3 +- src/mips/codegen-mips.cc | 23 +- src/mips/cpu-mips.cc | 4 +- src/mips/disasm-mips.cc | 2 +- src/mips/macro-assembler-mips.cc | 8 +- src/mips/macro-assembler-mips.h | 3 +- src/mips/regexp-macro-assembler-mips.cc | 2 +- src/mips/simulator-mips.cc | 19 +- src/mksnapshot.cc | 8 +- src/natives-external.cc | 2 +- src/objects-inl.h | 10 +- src/objects.cc | 8 +- src/objects.h | 2 +- src/optimizing-compiler-thread.cc | 16 +- src/optimizing-compiler-thread.h | 22 +- src/parser.cc | 6 +- src/preparse-data.cc | 2 +- src/preparser.cc | 2 +- src/prettyprinter.cc | 2 +- src/profile-generator.cc | 30 ++- src/profile-generator.h | 20 +- src/runtime-profiler.cc | 2 +- src/runtime-profiler.h | 6 +- src/runtime.cc | 22 +- src/sampler.cc | 32 +-- src/sampler.h | 2 +- src/scanner.h | 2 +- src/serialize.cc | 4 +- src/small-pointer-list.h | 2 +- src/snapshot-common.cc | 4 +- src/snapshot-source-sink.cc | 2 +- src/snapshot-source-sink.h | 2 +- src/spaces-inl.h | 10 +- src/spaces.cc | 66 +++--- src/spaces.h | 24 +-- src/store-buffer.cc | 7 +- src/store-buffer.h | 8 +- src/sweeper-thread.cc | 2 +- src/sweeper-thread.h | 10 +- src/token.h | 2 +- src/transitions.h | 2 +- src/unicode-inl.h | 2 +- src/utils.cc | 28 +-- src/utils.h | 85 +------- src/utils/DEPS | 5 - src/v8.cc | 4 +- src/v8.h | 2 +- src/v8checks.h | 39 ---- src/v8threads.h | 2 +- src/x64/assembler-x64-inl.h | 26 +-- src/x64/assembler-x64.cc | 4 +- src/x64/code-stubs-x64.h | 2 +- src/x64/codegen-x64.cc | 25 ++- src/x64/cpu-x64.cc | 4 +- src/x64/lithium-codegen-x64.h | 2 +- src/x64/macro-assembler-x64.cc | 10 +- src/x87/assembler-x87-inl.h | 26 +-- src/x87/assembler-x87.cc | 4 +- src/x87/code-stubs-x87.h | 2 +- src/x87/codegen-x87.cc | 9 +- src/x87/cpu-x87.cc | 4 +- src/x87/lithium-codegen-x87.h | 2 +- src/x87/macro-assembler-x87.cc | 10 +- src/zone.h | 2 +- test/cctest/cctest.h | 6 +- test/cctest/profiler-extension.cc | 2 +- test/cctest/test-api.cc | 54 ++--- test/cctest/test-assembler-arm64.cc | 12 +- test/cctest/test-assembler-ia32.cc | 6 +- test/cctest/test-assembler-x64.cc | 74 +++---- test/cctest/test-assembler-x87.cc | 4 +- test/cctest/test-bignum-dtoa.cc | 2 +- test/cctest/test-bignum.cc | 2 +- test/cctest/test-circular-queue.cc | 8 +- test/cctest/test-code-stubs-arm.cc | 9 +- test/cctest/test-code-stubs-arm64.cc | 9 +- test/cctest/test-code-stubs-ia32.cc | 7 +- test/cctest/test-code-stubs-mips.cc | 9 +- test/cctest/test-code-stubs-x64.cc | 7 +- test/cctest/test-code-stubs-x87.cc | 7 +- test/cctest/test-code-stubs.cc | 4 +- test/cctest/test-condition-variable.cc | 77 +++---- test/cctest/test-conversions.cc | 11 +- test/cctest/test-cpu-ia32.cc | 4 +- test/cctest/test-cpu-profiler.cc | 17 +- test/cctest/test-cpu-x64.cc | 4 +- test/cctest/test-cpu-x87.cc | 4 +- test/cctest/test-cpu.cc | 6 +- test/cctest/test-debug.cc | 42 ++-- test/cctest/test-deoptimization.cc | 4 +- test/cctest/test-diy-fp.cc | 2 +- test/cctest/test-double.cc | 6 +- test/cctest/test-dtoa.cc | 2 +- test/cctest/test-fast-dtoa.cc | 2 +- test/cctest/test-fixed-dtoa.cc | 2 +- test/cctest/test-javascript-arm64.cc | 2 +- test/cctest/test-js-arm64-variables.cc | 2 +- test/cctest/test-libplatform.h | 12 +- test/cctest/test-lockers.cc | 8 +- test/cctest/test-macro-assembler-arm.cc | 11 +- test/cctest/test-macro-assembler-ia32.cc | 7 +- test/cctest/test-macro-assembler-mips.cc | 6 +- test/cctest/test-macro-assembler-x64.cc | 135 ++++-------- test/cctest/test-macro-assembler-x87.cc | 7 +- test/cctest/test-mutex.cc | 46 ++-- test/cctest/test-parsing.cc | 12 +- test/cctest/test-platform-linux.cc | 6 +- test/cctest/test-platform-tls.cc | 6 +- test/cctest/test-platform-win32.cc | 6 +- test/cctest/test-platform.cc | 4 +- test/cctest/test-random-number-generator.cc | 12 +- test/cctest/test-semaphore.cc | 37 ++-- test/cctest/test-serialize.cc | 6 +- test/cctest/test-spaces.cc | 12 +- test/cctest/test-strtod.cc | 4 +- test/cctest/test-thread-termination.cc | 10 +- test/cctest/test-threads.cc | 20 +- test/cctest/test-time.cc | 1 + test/cctest/test-types.cc | 6 +- test/cctest/test-utils.cc | 4 +- tools/gyp/v8.gyp | 262 ++++++++++++----------- tools/lexer-shell.cc | 22 +- tools/parser-shell.cc | 17 +- 253 files changed, 1965 insertions(+), 1932 deletions(-) rename src/{ => base}/cpu.cc (99%) rename src/{ => base}/cpu.h (92%) create mode 100644 src/base/logging.cc create mode 100644 src/base/logging.h rename src/{ => base}/platform/condition-variable.cc (98%) rename src/{ => base}/platform/condition-variable.h (90%) rename src/{ => base}/platform/elapsed-timer.h (90%) rename src/{ => base}/platform/mutex.cc (97%) rename src/{ => base}/platform/mutex.h (92%) rename src/{ => base/platform}/platform-cygwin.cc (98%) rename src/{ => base/platform}/platform-freebsd.cc (98%) rename src/{ => base/platform}/platform-linux.cc (99%) rename src/{ => base/platform}/platform-macos.cc (98%) rename src/{ => base/platform}/platform-openbsd.cc (98%) rename src/{ => base/platform}/platform-posix.cc (98%) rename src/{ => base/platform}/platform-qnx.cc (98%) rename src/{ => base/platform}/platform-solaris.cc (98%) rename src/{ => base/platform}/platform-win32.cc (98%) rename src/{ => base/platform}/platform.h (98%) rename src/{ => base}/platform/semaphore.cc (96%) rename src/{ => base}/platform/semaphore.h (88%) rename src/{ => base}/platform/time.cc (95%) rename src/{ => base}/platform/time.h (98%) rename src/{ => base}/qnx-math.h (77%) rename src/{ => base}/utils/random-number-generator.cc (95%) rename src/{ => base}/utils/random-number-generator.h (94%) rename src/{ => base}/win32-math.cc (97%) rename src/{ => base}/win32-math.h (90%) delete mode 100644 src/utils/DEPS delete mode 100644 src/v8checks.h diff --git a/BUILD.gn b/BUILD.gn index 9f4d83d..18e5ef2 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -488,8 +488,6 @@ source_set("v8_base") { "src/cpu-profiler-inl.h", "src/cpu-profiler.cc", "src/cpu-profiler.h", - "src/cpu.cc", - "src/cpu.h", "src/data-flow.cc", "src/data-flow.h", "src/date.cc", @@ -680,16 +678,6 @@ source_set("v8_base") { "src/ostreams.h", "src/parser.cc", "src/parser.h", - "src/platform/elapsed-timer.h", - "src/platform/time.cc", - "src/platform/time.h", - "src/platform.h", - "src/platform/condition-variable.cc", - "src/platform/condition-variable.h", - "src/platform/mutex.cc", - "src/platform/mutex.h", - "src/platform/semaphore.cc", - "src/platform/semaphore.h", "src/preparse-data-format.h", "src/preparse-data.cc", "src/preparse-data.h", @@ -775,11 +763,8 @@ source_set("v8_base") { "src/utils-inl.h", "src/utils.cc", "src/utils.h", - "src/utils/random-number-generator.cc", - "src/utils/random-number-generator.h", "src/v8.cc", "src/v8.h", - "src/v8checks.h", "src/v8memory.h", "src/v8threads.cc", "src/v8threads.h", @@ -973,54 +958,12 @@ source_set("v8_base") { defines = [] deps = [ ":v8_libbase" ] - if (is_posix) { - sources += [ - "src/platform-posix.cc" - ] - } - if (is_linux) { - sources += [ - "src/platform-linux.cc" - ] - - libs = [ "rt" ] if (v8_compress_startup_data == "bz2") { libs += [ "bz2" ] } - } else if (is_android) { - defines += [ "CAN_USE_VFP_INSTRUCTIONS" ] - - if (build_os == "mac") { - if (current_toolchain == host_toolchain) { - sources += [ "src/platform-macos.cc" ] - } else { - sources += [ "src/platform-linux.cc" ] - } - } else { - sources += [ "src/platform-linux.cc" ] - if (current_toolchain == host_toolchain) { - defines += [ "V8_LIBRT_NOT_AVAILABLE" ] - } - } - } else if (is_mac) { - sources += [ "src/platform-macos.cc" ] - } else if (is_win) { - # TODO(jochen): Add support for cygwin. - sources += [ - "src/platform-win32.cc", - "src/win32-math.cc", - "src/win32-math.h", - ] - - defines += [ "_CRT_RAND_S" ] # for rand_s() - - libs = [ "winmm.lib", "ws2_32.lib" ] } - # TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris. - - if (v8_enable_i18n_support) { deps += [ "//third_party/icu" ] if (is_win) { @@ -1056,20 +999,82 @@ source_set("v8_libbase") { "src/base/atomicops_internals_x86_gcc.h", "src/base/atomicops_internals_x86_msvc.h", "src/base/build_config.h", + "src/base/cpu.cc", + "src/base/cpu.h", "src/base/lazy-instance.h", + "src/base/logging.cc", + "src/base/logging.h", "src/base/macros.h", "src/base/once.cc", "src/base/once.h", + "src/base/platform/elapsed-timer.h", + "src/base/platform/time.cc", + "src/base/platform/time.h", + "src/base/platform/condition-variable.cc", + "src/base/platform/condition-variable.h", + "src/base/platform/mutex.cc", + "src/base/platform/mutex.h", + "src/base/platform/platform.h", + "src/base/platform/semaphore.cc", + "src/base/platform/semaphore.h", "src/base/safe_conversions.h", "src/base/safe_conversions_impl.h", "src/base/safe_math.h", "src/base/safe_math_impl.h", - "src/base/win32-headers.h", + "src/base/utils/random-number-generator.cc", + "src/base/utils/random-number-generator.h", ] configs -= [ "//build/config/compiler:chromium_code" ] configs += [ "//build/config/compiler:no_chromium_code" ] configs += [ ":internal_config", ":features", ":toolchain" ] + + defines = [] + + if (is_posix) { + sources += [ + "src/base/platform/platform-posix.cc" + ] + } + + if (is_linux) { + sources += [ + "src/base/platform/platform-linux.cc" + ] + + libs = [ "rt" ] + } else if (is_android) { + defines += [ "CAN_USE_VFP_INSTRUCTIONS" ] + + if (build_os == "mac") { + if (current_toolchain == host_toolchain) { + sources += [ "src/base/platform/platform-macos.cc" ] + } else { + sources += [ "src/base/platform/platform-linux.cc" ] + } + } else { + sources += [ "src/base/platform/platform-linux.cc" ] + if (current_toolchain == host_toolchain) { + defines += [ "V8_LIBRT_NOT_AVAILABLE" ] + } + } + } else if (is_mac) { + sources += [ "src/base/platform/platform-macos.cc" ] + } else if (is_win) { + # TODO(jochen): Add support for cygwin. + sources += [ + "src/base/platform/platform-win32.cc", + "src/base/platform/win32-headers.h", + "src/base/platform/win32-math.cc", + "src/base/platform/win32-math.h", + ] + + defines += [ "_CRT_RAND_S" ] # for rand_s() + + libs = [ "winmm.lib", "ws2_32.lib" ] + } + + # TODO(jochen): Add support for qnx, freebsd, openbsd, netbsd, and solaris. } ############################################################################### diff --git a/src/allocation-tracker.cc b/src/allocation-tracker.cc index e463f0c..43dcd59 100644 --- a/src/allocation-tracker.cc +++ b/src/allocation-tracker.cc @@ -54,15 +54,15 @@ void AllocationTraceNode::AddAllocation(unsigned size) { void AllocationTraceNode::Print(int indent, AllocationTracker* tracker) { - OS::Print("%10u %10u %*c", total_size_, allocation_count_, indent, ' '); + base::OS::Print("%10u %10u %*c", total_size_, allocation_count_, indent, ' '); if (tracker != NULL) { AllocationTracker::FunctionInfo* info = tracker->function_info_list()[function_info_index_]; - OS::Print("%s #%u", info->name, id_); + base::OS::Print("%s #%u", info->name, id_); } else { - OS::Print("%u #%u", function_info_index_, id_); + base::OS::Print("%u #%u", function_info_index_, id_); } - OS::Print("\n"); + base::OS::Print("\n"); indent += 2; for (int i = 0; i < children_.length(); i++) { children_[i]->Print(indent, tracker); @@ -93,8 +93,8 @@ AllocationTraceNode* AllocationTraceTree::AddPathFromEnd( void AllocationTraceTree::Print(AllocationTracker* tracker) { - OS::Print("[AllocationTraceTree:]\n"); - OS::Print("Total size | Allocation count | Function id | id\n"); + base::OS::Print("[AllocationTraceTree:]\n"); + base::OS::Print("Total size | Allocation count | Function id | id\n"); root()->Print(0, tracker); } diff --git a/src/allocation.cc b/src/allocation.cc index 98c9be2..2af6730 100644 --- a/src/allocation.cc +++ b/src/allocation.cc @@ -5,8 +5,8 @@ #include "src/allocation.h" #include // For free, malloc. -#include "src/checks.h" -#include "src/platform.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" #include "src/utils.h" #if V8_LIBC_BIONIC diff --git a/src/api.cc b/src/api.cc index cd23d93..cb26f6f 100644 --- a/src/api.cc +++ b/src/api.cc @@ -13,6 +13,9 @@ #include "include/v8-profiler.h" #include "include/v8-testing.h" #include "src/assert-scope.h" +#include "src/base/platform/platform.h" +#include "src/base/platform/time.h" +#include "src/base/utils/random-number-generator.h" #include "src/bootstrapper.h" #include "src/code-stubs.h" #include "src/compiler.h" @@ -30,8 +33,6 @@ #include "src/messages.h" #include "src/natives.h" #include "src/parser.h" -#include "src/platform.h" -#include "src/platform/time.h" #include "src/profile-generator-inl.h" #include "src/property.h" #include "src/property-details.h" @@ -41,7 +42,6 @@ #include "src/simulator.h" #include "src/snapshot.h" #include "src/unicode-inl.h" -#include "src/utils/random-number-generator.h" #include "src/v8threads.h" #include "src/version.h" #include "src/vm-state-inl.h" @@ -174,9 +174,9 @@ void Utils::ReportApiFailure(const char* location, const char* message) { i::Isolate* isolate = i::Isolate::Current(); FatalErrorCallback callback = isolate->exception_behavior(); if (callback == NULL) { - i::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", - location, message); - i::OS::Abort(); + base::OS::PrintError("\n#\n# Fatal error in %s\n# %s\n#\n\n", location, + message); + base::OS::Abort(); } else { callback(location, message); } @@ -2823,7 +2823,7 @@ double Value::NumberValue() const { EXCEPTION_PREAMBLE(isolate); has_pending_exception = !i::Execution::ToNumber( isolate, obj).ToHandle(&num); - EXCEPTION_BAILOUT_CHECK(isolate, i::OS::nan_value()); + EXCEPTION_BAILOUT_CHECK(isolate, base::OS::nan_value()); } return num->Number(); } @@ -4959,7 +4959,7 @@ bool v8::V8::Initialize() { void v8::V8::SetEntropySource(EntropySource entropy_source) { - i::RandomNumberGenerator::SetEntropySource(entropy_source); + base::RandomNumberGenerator::SetEntropySource(entropy_source); } @@ -5669,7 +5669,7 @@ Local v8::Date::New(Isolate* isolate, double time) { LOG_API(i_isolate, "Date::New"); if (std::isnan(time)) { // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. - time = i::OS::nan_value(); + time = base::OS::nan_value(); } ENTER_V8(i_isolate); EXCEPTION_PREAMBLE(i_isolate); @@ -6239,7 +6239,7 @@ Local v8::Number::New(Isolate* isolate, double value) { ASSERT(internal_isolate->IsInitialized()); if (std::isnan(value)) { // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. - value = i::OS::nan_value(); + value = base::OS::nan_value(); } ENTER_V8(internal_isolate); i::Handle result = internal_isolate->factory()->NewNumber(value); @@ -7095,19 +7095,20 @@ const CpuProfileNode* CpuProfile::GetSample(int index) const { int64_t CpuProfile::GetSampleTimestamp(int index) const { const i::CpuProfile* profile = reinterpret_cast(this); - return (profile->sample_timestamp(index) - i::TimeTicks()).InMicroseconds(); + return (profile->sample_timestamp(index) - base::TimeTicks()) + .InMicroseconds(); } int64_t CpuProfile::GetStartTime() const { const i::CpuProfile* profile = reinterpret_cast(this); - return (profile->start_time() - i::TimeTicks()).InMicroseconds(); + return (profile->start_time() - base::TimeTicks()).InMicroseconds(); } int64_t CpuProfile::GetEndTime() const { const i::CpuProfile* profile = reinterpret_cast(this); - return (profile->end_time() - i::TimeTicks()).InMicroseconds(); + return (profile->end_time() - base::TimeTicks()).InMicroseconds(); } @@ -7119,7 +7120,7 @@ int CpuProfile::GetSamplesCount() const { void CpuProfiler::SetSamplingInterval(int us) { ASSERT(us >= 0); return reinterpret_cast(this)->set_sampling_interval( - i::TimeDelta::FromMicroseconds(us)); + base::TimeDelta::FromMicroseconds(us)); } diff --git a/src/arm/assembler-arm-inl.h b/src/arm/assembler-arm-inl.h index 0ca2314..2c44c78 100644 --- a/src/arm/assembler-arm-inl.h +++ b/src/arm/assembler-arm-inl.h @@ -39,7 +39,7 @@ #include "src/arm/assembler-arm.h" -#include "src/cpu.h" +#include "src/assembler.h" #include "src/debug.h" @@ -527,7 +527,7 @@ void Assembler::set_target_address_at(Address pc, Memory::Address_at(constant_pool_entry_address(pc, constant_pool)) = target; // Intuitively, we would think it is necessary to always flush the // instruction cache after patching a target address in the code as follows: - // CPU::FlushICache(pc, sizeof(target)); + // CpuFeatures::FlushICache(pc, sizeof(target)); // However, on ARM, no instruction is actually patched in the case // of embedded constants of the form: // ldr ip, [pp, #...] @@ -545,7 +545,7 @@ void Assembler::set_target_address_at(Address pc, ASSERT(IsMovW(Memory::int32_at(pc))); ASSERT(IsMovT(Memory::int32_at(pc + kInstrSize))); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc, 2 * kInstrSize); + CpuFeatures::FlushICache(pc, 2 * kInstrSize); } } } diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc index 78e0f38..fbcaaef 100644 --- a/src/arm/assembler-arm.cc +++ b/src/arm/assembler-arm.cc @@ -93,7 +93,7 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { #else // __arm__ // Probe for additional features at runtime. - CPU cpu; + base::CPU cpu; if (FLAG_enable_vfp3 && cpu.has_vfp3()) { // This implementation also sets the VFP flags if runtime // detection of VFP returns true. VFPv3 implies ARMv7, see ARM DDI @@ -109,14 +109,15 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { if (FLAG_enable_armv7) supported_ |= 1u << ARMv7; if (FLAG_enable_unaligned_accesses) supported_ |= 1u << UNALIGNED_ACCESSES; // Use movw/movt for QUALCOMM ARMv7 cores. - if (FLAG_enable_movw_movt && cpu.implementer() == CPU::QUALCOMM) { + if (FLAG_enable_movw_movt && cpu.implementer() == base::CPU::QUALCOMM) { supported_ |= 1u << MOVW_MOVT_IMMEDIATE_LOADS; } } // ARM Cortex-A9 and Cortex-A5 have 32 byte cachelines. - if (cpu.implementer() == CPU::ARM && (cpu.part() == CPU::ARM_CORTEX_A5 || - cpu.part() == CPU::ARM_CORTEX_A9)) { + if (cpu.implementer() == base::CPU::ARM && + (cpu.part() == base::CPU::ARM_CORTEX_A5 || + cpu.part() == base::CPU::ARM_CORTEX_A9)) { cache_line_size_ = 32; } @@ -162,7 +163,7 @@ void CpuFeatures::PrintTarget() { #endif #ifdef __arm__ - arm_float_abi = OS::ArmUsingHardFloat() ? "hard" : "softfp"; + arm_float_abi = base::OS::ArmUsingHardFloat() ? "hard" : "softfp"; #elif USE_EABI_HARDFLOAT arm_float_abi = "hard"; #else @@ -191,7 +192,7 @@ void CpuFeatures::PrintFeatures() { CpuFeatures::IsSupported(UNALIGNED_ACCESSES), CpuFeatures::IsSupported(MOVW_MOVT_IMMEDIATE_LOADS)); #ifdef __arm__ - bool eabi_hardfloat = OS::ArmUsingHardFloat(); + bool eabi_hardfloat = base::OS::ArmUsingHardFloat(); #elif USE_EABI_HARDFLOAT bool eabi_hardfloat = true; #else @@ -246,7 +247,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count * Assembler::kInstrSize); + CpuFeatures::FlushICache(pc_, instruction_count * Assembler::kInstrSize); } diff --git a/src/arm/code-stubs-arm.h b/src/arm/code-stubs-arm.h index d5b7b28..eb7d2c6 100644 --- a/src/arm/code-stubs-arm.h +++ b/src/arm/code-stubs-arm.h @@ -229,7 +229,8 @@ class RecordWriteStub: public PlatformCodeStub { break; } ASSERT(GetMode(stub) == mode); - CPU::FlushICache(stub->instruction_start(), 2 * Assembler::kInstrSize); + CpuFeatures::FlushICache(stub->instruction_start(), + 2 * Assembler::kInstrSize); } private: diff --git a/src/arm/codegen-arm.cc b/src/arm/codegen-arm.cc index aa29700..aba7fd4 100644 --- a/src/arm/codegen-arm.cc +++ b/src/arm/codegen-arm.cc @@ -29,7 +29,8 @@ double fast_exp_simulator(double x) { UnaryMathFunction CreateExpFunction() { if (!FLAG_fast_math) return &std::exp; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::exp; ExternalReference::InitializeMathExpData(); @@ -66,8 +67,8 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); #if !defined(USE_SIMULATOR) return FUNCTION_CAST(buffer); @@ -84,7 +85,8 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { #else if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return stub; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); @@ -225,8 +227,8 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif } @@ -240,7 +242,8 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( #else if (!CpuFeatures::IsSupported(UNALIGNED_ACCESSES)) return stub; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return stub; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); @@ -311,8 +314,8 @@ MemCopyUint16Uint8Function CreateMemCopyUint16Uint8Function( CodeDesc desc; masm.GetCode(&desc); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif @@ -324,7 +327,8 @@ UnaryMathFunction CreateSqrtFunction() { return &std::sqrt; #else size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::sqrt; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); @@ -338,8 +342,8 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif } @@ -874,7 +878,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CPU::FlushICache(sequence, young_length); + CpuFeatures::FlushICache(sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); diff --git a/src/arm/cpu-arm.cc b/src/arm/cpu-arm.cc index 6412366..9c7104e 100644 --- a/src/arm/cpu-arm.cc +++ b/src/arm/cpu-arm.cc @@ -16,7 +16,7 @@ #if V8_TARGET_ARCH_ARM -#include "src/cpu.h" +#include "src/assembler.h" #include "src/macro-assembler.h" #include "src/simulator.h" // for cache flushing. @@ -24,7 +24,7 @@ namespace v8 { namespace internal { -void CPU::FlushICache(void* start, size_t size) { +void CpuFeatures::FlushICache(void* start, size_t size) { if (size == 0) return; #if defined(USE_SIMULATOR) diff --git a/src/arm/disasm-arm.cc b/src/arm/disasm-arm.cc index 1038755..70b1eb8 100644 --- a/src/arm/disasm-arm.cc +++ b/src/arm/disasm-arm.cc @@ -33,9 +33,9 @@ #if V8_TARGET_ARCH_ARM #include "src/arm/constants-arm.h" +#include "src/base/platform/platform.h" #include "src/disasm.h" #include "src/macro-assembler.h" -#include "src/platform.h" namespace v8 { diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index ecb8b19..c35fb9e 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -1144,7 +1144,7 @@ int MacroAssembler::ActivationFrameAlignment() { // environment. // Note: This will break if we ever start generating snapshots on one ARM // platform for another ARM platform with a different alignment. - return OS::ActivationFrameAlignment(); + return base::OS::ActivationFrameAlignment(); #else // V8_HOST_ARCH_ARM // If we are using the simulator then we should always align to the expected // alignment. As the simulator is used to generate snapshots we do not know @@ -3595,7 +3595,7 @@ void MacroAssembler::CallCFunctionHelper(Register function, // provides more information. #if V8_HOST_ARCH_ARM if (emit_debug_code()) { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); int frame_alignment_mask = frame_alignment - 1; if (frame_alignment > kPointerSize) { ASSERT(IsPowerOf2(frame_alignment)); @@ -4040,7 +4040,7 @@ CodePatcher::CodePatcher(byte* address, CodePatcher::~CodePatcher() { // Indicate that code has changed. if (flush_cache_ == FLUSH) { - CPU::FlushICache(address_, size_); + CpuFeatures::FlushICache(address_, size_); } // Check that the code was patched as expected. diff --git a/src/arm/macro-assembler-arm.h b/src/arm/macro-assembler-arm.h index dbf305a..2d91575 100644 --- a/src/arm/macro-assembler-arm.h +++ b/src/arm/macro-assembler-arm.h @@ -1180,7 +1180,7 @@ class MacroAssembler: public Assembler { // EABI variant for double arguments in use. bool use_eabi_hardfloat() { #ifdef __arm__ - return OS::ArmUsingHardFloat(); + return base::OS::ArmUsingHardFloat(); #elif USE_EABI_HARDFLOAT return true; #else diff --git a/src/arm/regexp-macro-assembler-arm.cc b/src/arm/regexp-macro-assembler-arm.cc index e45f8cc..2300716 100644 --- a/src/arm/regexp-macro-assembler-arm.cc +++ b/src/arm/regexp-macro-assembler-arm.cc @@ -1011,7 +1011,7 @@ void RegExpMacroAssemblerARM::CallCheckStackGuardState(Register scratch) { __ mov(r1, Operand(masm_->CodeObject())); // We need to make room for the return address on the stack. - int stack_alignment = OS::ActivationFrameAlignment(); + int stack_alignment = base::OS::ActivationFrameAlignment(); ASSERT(IsAligned(stack_alignment, kPointerSize)); __ sub(sp, sp, Operand(stack_alignment)); diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc index e987825..3518bfa 100644 --- a/src/arm/simulator-arm.cc +++ b/src/arm/simulator-arm.cc @@ -451,7 +451,7 @@ void ArmDebugger::Debug() { } } else if (strcmp(cmd, "gdb") == 0) { PrintF("relinquishing control to gdb\n"); - v8::internal::OS::DebugBreak(); + v8::base::OS::DebugBreak(); PrintF("regaining control from gdb\n"); } else if (strcmp(cmd, "break") == 0) { if (argc == 2) { @@ -3763,8 +3763,8 @@ int32_t Simulator::Call(byte* entry, int argument_count, ...) { int original_stack = get_register(sp); // Compute position of stack on entry to generated code. int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t)); - if (OS::ActivationFrameAlignment() != 0) { - entry_stack &= -OS::ActivationFrameAlignment(); + if (base::OS::ActivationFrameAlignment() != 0) { + entry_stack &= -base::OS::ActivationFrameAlignment(); } // Store remaining arguments on stack, from low to high memory. intptr_t* stack_argument = reinterpret_cast(entry_stack); diff --git a/src/arm64/assembler-arm64-inl.h b/src/arm64/assembler-arm64-inl.h index 135858d..444f2c4 100644 --- a/src/arm64/assembler-arm64-inl.h +++ b/src/arm64/assembler-arm64-inl.h @@ -6,7 +6,7 @@ #define V8_ARM64_ASSEMBLER_ARM64_INL_H_ #include "src/arm64/assembler-arm64.h" -#include "src/cpu.h" +#include "src/assembler.h" #include "src/debug.h" @@ -652,7 +652,7 @@ void Assembler::set_target_address_at(Address pc, Memory::Address_at(target_pointer_address_at(pc)) = target; // Intuitively, we would think it is necessary to always flush the // instruction cache after patching a target address in the code as follows: - // CPU::FlushICache(pc, sizeof(target)); + // CpuFeatures::FlushICache(pc, sizeof(target)); // However, on ARM, an instruction is actually patched in the case of // embedded constants of the form: // ldr ip, [pc, #...] diff --git a/src/arm64/assembler-arm64.cc b/src/arm64/assembler-arm64.cc index ee41875..b349421 100644 --- a/src/arm64/assembler-arm64.cc +++ b/src/arm64/assembler-arm64.cc @@ -33,6 +33,7 @@ #define ARM64_DEFINE_REG_STATICS #include "src/arm64/assembler-arm64-inl.h" +#include "src/base/cpu.h" namespace v8 { namespace internal { @@ -47,9 +48,9 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { // csp will always be aligned if it is enabled by probing at runtime. if (FLAG_enable_always_align_csp) supported_ |= 1u << ALWAYS_ALIGN_CSP; } else { - CPU cpu; - if (FLAG_enable_always_align_csp && (cpu.implementer() == CPU::NVIDIA || - FLAG_debug_code)) { + base::CPU cpu; + if (FLAG_enable_always_align_csp && + (cpu.implementer() == base::CPU::NVIDIA || FLAG_debug_code)) { supported_ |= 1u << ALWAYS_ALIGN_CSP; } } @@ -190,7 +191,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count * kInstructionSize); + CpuFeatures::FlushICache(pc_, instruction_count * kInstructionSize); } diff --git a/src/arm64/assembler-arm64.h b/src/arm64/assembler-arm64.h index f737931..a92be4b 100644 --- a/src/arm64/assembler-arm64.h +++ b/src/arm64/assembler-arm64.h @@ -11,7 +11,6 @@ #include "src/arm64/instructions-arm64.h" #include "src/assembler.h" -#include "src/cpu.h" #include "src/globals.h" #include "src/serialize.h" #include "src/utils.h" @@ -2284,7 +2283,7 @@ class PatchingAssembler : public Assembler { ASSERT(IsConstPoolEmpty()); // Flush the Instruction cache. size_t length = buffer_size_ - kGap; - CPU::FlushICache(buffer_, length); + CpuFeatures::FlushICache(buffer_, length); } static const int kMovInt64NInstrs = 4; diff --git a/src/arm64/codegen-arm64.cc b/src/arm64/codegen-arm64.cc index d5080f1..cf8c0ed 100644 --- a/src/arm64/codegen-arm64.cc +++ b/src/arm64/codegen-arm64.cc @@ -35,7 +35,8 @@ UnaryMathFunction CreateExpFunction() { // an AAPCS64-compliant exp() function. This will be faster than the C // library's exp() function, but probably less accurate. size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::exp; ExternalReference::InitializeMathExpData(); @@ -63,8 +64,8 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); #if !defined(USE_SIMULATOR) return FUNCTION_CAST(buffer); diff --git a/src/arm64/cpu-arm64.cc b/src/arm64/cpu-arm64.cc index 5c150d1..4a7bbfe 100644 --- a/src/arm64/cpu-arm64.cc +++ b/src/arm64/cpu-arm64.cc @@ -9,7 +9,7 @@ #if V8_TARGET_ARCH_ARM64 #include "src/arm64/utils-arm64.h" -#include "src/cpu.h" +#include "src/assembler.h" namespace v8 { namespace internal { @@ -40,7 +40,7 @@ class CacheLineSizes { }; -void CPU::FlushICache(void* address, size_t length) { +void CpuFeatures::FlushICache(void* address, size_t length) { if (length == 0) return; #ifdef USE_SIMULATOR diff --git a/src/arm64/disasm-arm64.cc b/src/arm64/disasm-arm64.cc index de24481..05a6b8a 100644 --- a/src/arm64/disasm-arm64.cc +++ b/src/arm64/disasm-arm64.cc @@ -13,9 +13,9 @@ #include "src/arm64/decoder-arm64-inl.h" #include "src/arm64/disasm-arm64.h" +#include "src/base/platform/platform.h" #include "src/disasm.h" #include "src/macro-assembler.h" -#include "src/platform.h" namespace v8 { namespace internal { diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc index 43796b1..ea6b356 100644 --- a/src/arm64/macro-assembler-arm64.cc +++ b/src/arm64/macro-assembler-arm64.cc @@ -1898,7 +1898,7 @@ int MacroAssembler::ActivationFrameAlignment() { // environment. // Note: This will break if we ever start generating snapshots on one ARM // platform for another ARM platform with a different alignment. - return OS::ActivationFrameAlignment(); + return base::OS::ActivationFrameAlignment(); #else // V8_HOST_ARCH_ARM64 // If we are using the simulator then we should always align to the expected // alignment. As the simulator is used to generate snapshots we do not know diff --git a/src/arm64/simulator-arm64.cc b/src/arm64/simulator-arm64.cc index 3392aa0..a4d69b4 100644 --- a/src/arm64/simulator-arm64.cc +++ b/src/arm64/simulator-arm64.cc @@ -61,7 +61,7 @@ void Simulator::TraceSim(const char* format, ...) { if (FLAG_trace_sim) { va_list arguments; va_start(arguments, format); - OS::VFPrint(stream_, format, arguments); + base::OS::VFPrint(stream_, format, arguments); va_end(arguments); } } @@ -143,8 +143,8 @@ void Simulator::CallVoid(byte* entry, CallArgument* args) { uintptr_t original_stack = sp(); uintptr_t entry_stack = original_stack - stack_args.size() * sizeof(stack_args[0]); - if (OS::ActivationFrameAlignment() != 0) { - entry_stack &= -OS::ActivationFrameAlignment(); + if (base::OS::ActivationFrameAlignment() != 0) { + entry_stack &= -base::OS::ActivationFrameAlignment(); } char * stack = reinterpret_cast(entry_stack); std::vector::const_iterator it; @@ -3444,7 +3444,7 @@ void Simulator::Debug() { // gdb ------------------------------------------------------------------- } else if (strcmp(cmd, "gdb") == 0) { PrintF("Relinquishing control to gdb.\n"); - OS::DebugBreak(); + base::OS::DebugBreak(); PrintF("Regaining control from gdb.\n"); // sysregs --------------------------------------------------------------- @@ -3592,7 +3592,7 @@ void Simulator::VisitException(Instruction* instr) { abort(); } else { - OS::DebugBreak(); + base::OS::DebugBreak(); } break; } diff --git a/src/assembler.cc b/src/assembler.cc index 63f9c56..923606e 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -36,10 +36,11 @@ #include #include "src/api.h" +#include "src/base/cpu.h" #include "src/base/lazy-instance.h" +#include "src/base/platform/platform.h" #include "src/builtins.h" #include "src/counters.h" -#include "src/cpu.h" #include "src/cpu-profiler.h" #include "src/debug.h" #include "src/deoptimizer.h" @@ -47,7 +48,6 @@ #include "src/ic.h" #include "src/isolate-inl.h" #include "src/jsregexp.h" -#include "src/platform.h" #include "src/regexp-macro-assembler.h" #include "src/regexp-stack.h" #include "src/runtime.h" @@ -98,16 +98,16 @@ namespace internal { // Common double constants. struct DoubleConstant BASE_EMBEDDED { - double min_int; - double one_half; - double minus_one_half; - double minus_zero; - double zero; - double uint8_max_value; - double negative_infinity; - double canonical_non_hole_nan; - double the_hole_nan; - double uint32_bias; +double min_int; +double one_half; +double minus_one_half; +double minus_zero; +double zero; +double uint8_max_value; +double negative_infinity; +double canonical_non_hole_nan; +double the_hole_nan; +double uint32_bias; }; static DoubleConstant double_constants; @@ -115,7 +115,7 @@ static DoubleConstant double_constants; const char* const RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; static bool math_exp_data_initialized = false; -static Mutex* math_exp_data_mutex = NULL; +static base::Mutex* math_exp_data_mutex = NULL; static double* math_exp_constants_array = NULL; static double* math_exp_log_table_array = NULL; @@ -907,13 +907,13 @@ void ExternalReference::SetUp() { double_constants.minus_zero = -0.0; double_constants.uint8_max_value = 255; double_constants.zero = 0.0; - double_constants.canonical_non_hole_nan = OS::nan_value(); + double_constants.canonical_non_hole_nan = base::OS::nan_value(); double_constants.the_hole_nan = BitCast(kHoleNanInt64); double_constants.negative_infinity = -V8_INFINITY; double_constants.uint32_bias = static_cast(static_cast(0xFFFFFFFF)) + 1; - math_exp_data_mutex = new Mutex(); + math_exp_data_mutex = new base::Mutex(); } @@ -921,7 +921,7 @@ void ExternalReference::InitializeMathExpData() { // Early return? if (math_exp_data_initialized) return; - LockGuard lock_guard(math_exp_data_mutex); + base::LockGuard lock_guard(math_exp_data_mutex); if (!math_exp_data_initialized) { // If this is changed, generated code must be adapted too. const int kTableSizeBits = 11; @@ -1031,7 +1031,8 @@ ExternalReference ExternalReference:: ExternalReference ExternalReference::flush_icache_function(Isolate* isolate) { - return ExternalReference(Redirect(isolate, FUNCTION_ADDR(CPU::FlushICache))); + return ExternalReference( + Redirect(isolate, FUNCTION_ADDR(CpuFeatures::FlushICache))); } @@ -1506,7 +1507,7 @@ double power_double_double(double x, double y) { // The checks for special cases can be dropped in ia32 because it has already // been done in generated code before bailing out here. if (std::isnan(y) || ((x == 1 || x == -1) && std::isinf(y))) { - return OS::nan_value(); + return base::OS::nan_value(); } return std::pow(x, y); } diff --git a/src/assembler.h b/src/assembler.h index c92706c..ea69953 100644 --- a/src/assembler.h +++ b/src/assembler.h @@ -189,6 +189,9 @@ class CpuFeatures : public AllStatic { static void PrintTarget(); static void PrintFeatures(); + // Flush instruction cache. + static void FlushICache(void* start, size_t size); + private: // Platform-dependent implementation. static void ProbeImpl(bool cross_compile); diff --git a/src/assert-scope.h b/src/assert-scope.h index 14e1194..7e1bc77 100644 --- a/src/assert-scope.h +++ b/src/assert-scope.h @@ -6,7 +6,7 @@ #define V8_ASSERT_SCOPE_H_ #include "src/allocation.h" -#include "src/platform.h" +#include "src/base/platform/platform.h" #include "src/utils.h" namespace v8 { @@ -81,16 +81,16 @@ class PerThreadAssertScopeBase { static PerThreadAssertData* GetAssertData() { return reinterpret_cast( - Thread::GetThreadLocal(thread_local_key)); + base::Thread::GetThreadLocal(thread_local_key)); } - static Thread::LocalStorageKey thread_local_key; + static base::Thread::LocalStorageKey thread_local_key; PerThreadAssertData* data_; friend class Isolate; private: static void SetThreadLocalData(PerThreadAssertData* data) { - Thread::SetThreadLocal(thread_local_key, data); + base::Thread::SetThreadLocal(thread_local_key, data); } }; diff --git a/src/base/build_config.h b/src/base/build_config.h index bdee4b4..3dc51f5 100644 --- a/src/base/build_config.h +++ b/src/base/build_config.h @@ -149,4 +149,8 @@ #define USING_BSD_ABI #endif +// Number of bits to represent the page size for paged spaces. The value of 20 +// gives 1Mb bytes per page. +const int kPageSizeBits = 20; + #endif // V8_BASE_BUILD_CONFIG_H_ diff --git a/src/cpu.cc b/src/base/cpu.cc similarity index 99% rename from src/cpu.cc rename to src/base/cpu.cc index 6b04e20..dc26dd7 100644 --- a/src/cpu.cc +++ b/src/base/cpu.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/cpu.h" +#include "src/base/cpu.h" #if V8_LIBC_MSVCRT #include // __cpuid() @@ -21,13 +21,13 @@ #include #include -#include "src/checks.h" +#include "src/base/logging.h" #if V8_OS_WIN #include "src/base/win32-headers.h" // NOLINT #endif namespace v8 { -namespace internal { +namespace base { #if V8_HOST_ARCH_IA32 || V8_HOST_ARCH_X64 @@ -495,4 +495,4 @@ CPU::CPU() : stepping_(0), #endif } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/cpu.h b/src/base/cpu.h similarity index 92% rename from src/cpu.h rename to src/base/cpu.h index ac8ee98..eb51674 100644 --- a/src/cpu.h +++ b/src/base/cpu.h @@ -10,13 +10,13 @@ // The build system then uses the implementation for the target architecture. // -#ifndef V8_CPU_H_ -#define V8_CPU_H_ +#ifndef V8_BASE_CPU_H_ +#define V8_BASE_CPU_H_ -#include "src/allocation.h" +#include "src/base/macros.h" namespace v8 { -namespace internal { +namespace base { // ---------------------------------------------------------------------------- // CPU @@ -28,7 +28,7 @@ namespace internal { // architectures. For each architecture the file cpu_.cc contains the // implementation of these static functions. -class CPU V8_FINAL BASE_EMBEDDED { +class CPU V8_FINAL { public: CPU(); @@ -77,9 +77,6 @@ class CPU V8_FINAL BASE_EMBEDDED { bool has_vfp3() const { return has_vfp3_; } bool has_vfp3_d32() const { return has_vfp3_d32_; } - // Flush instruction cache. - static void FlushICache(void* start, size_t size); - private: char vendor_[13]; int stepping_; @@ -109,6 +106,6 @@ class CPU V8_FINAL BASE_EMBEDDED { bool has_vfp3_d32_; }; -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_CPU_H_ +#endif // V8_BASE_CPU_H_ diff --git a/src/base/logging.cc b/src/base/logging.cc new file mode 100644 index 0000000..4f62ac4 --- /dev/null +++ b/src/base/logging.cc @@ -0,0 +1,88 @@ +// Copyright 2006-2008 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "src/base/logging.h" + +#if V8_LIBC_GLIBC || V8_OS_BSD +# include +# include +#elif V8_OS_QNX +# include +#endif // V8_LIBC_GLIBC || V8_OS_BSD +#include +#include + +#include "src/base/platform/platform.h" + +namespace v8 { +namespace base { + +// Attempts to dump a backtrace (if supported). +void DumpBacktrace() { +#if V8_LIBC_GLIBC || V8_OS_BSD + void* trace[100]; + int size = backtrace(trace, ARRAY_SIZE(trace)); + char** symbols = backtrace_symbols(trace, size); + OS::PrintError("\n==== C stack trace ===============================\n\n"); + if (size == 0) { + OS::PrintError("(empty)\n"); + } else if (symbols == NULL) { + OS::PrintError("(no symbols)\n"); + } else { + for (int i = 1; i < size; ++i) { + OS::PrintError("%2d: ", i); + char mangled[201]; + if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT + int status; + size_t length; + char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); + OS::PrintError("%s\n", demangled != NULL ? demangled : mangled); + free(demangled); + } else { + OS::PrintError("??\n"); + } + } + } + free(symbols); +#elif V8_OS_QNX + char out[1024]; + bt_accessor_t acc; + bt_memmap_t memmap; + bt_init_accessor(&acc, BT_SELF); + bt_load_memmap(&acc, &memmap); + bt_sprn_memmap(&memmap, out, sizeof(out)); + OS::PrintError(out); + bt_addr_t trace[100]; + int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace)); + OS::PrintError("\n==== C stack trace ===============================\n\n"); + if (size == 0) { + OS::PrintError("(empty)\n"); + } else { + bt_sprnf_addrs(&memmap, trace, size, const_cast("%a\n"), + out, sizeof(out), NULL); + OS::PrintError(out); + } + bt_unload_memmap(&memmap); + bt_release_accessor(&acc); +#endif // V8_LIBC_GLIBC || V8_OS_BSD +} + +} } // namespace v8::base + + +// Contains protection against recursive calls (faults while handling faults). +extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { + fflush(stdout); + fflush(stderr); + v8::base::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, + line); + va_list arguments; + va_start(arguments, format); + v8::base::OS::VPrintError(format, arguments); + va_end(arguments); + v8::base::OS::PrintError("\n#\n"); + v8::base::DumpBacktrace(); + fflush(stderr); + v8::base::OS::Abort(); +} diff --git a/src/base/logging.h b/src/base/logging.h new file mode 100644 index 0000000..de91077 --- /dev/null +++ b/src/base/logging.h @@ -0,0 +1,267 @@ +// Copyright 2012 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef V8_BASE_LOGGING_H_ +#define V8_BASE_LOGGING_H_ + +#include + +#include "include/v8stdint.h" +#include "src/base/build_config.h" + +extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); + + +// The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during +// development, but they should not be relied on in the final product. +#ifdef DEBUG +#define FATAL(msg) \ + V8_Fatal(__FILE__, __LINE__, "%s", (msg)) +#define UNIMPLEMENTED() \ + V8_Fatal(__FILE__, __LINE__, "unimplemented code") +#define UNREACHABLE() \ + V8_Fatal(__FILE__, __LINE__, "unreachable code") +#else +#define FATAL(msg) \ + V8_Fatal("", 0, "%s", (msg)) +#define UNIMPLEMENTED() \ + V8_Fatal("", 0, "unimplemented code") +#define UNREACHABLE() ((void) 0) +#endif + + +// The CHECK macro checks that the given condition is true; if not, it +// prints a message to stderr and aborts. +#define CHECK(condition) do { \ + if (!(condition)) { \ + V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ + } \ + } while (0) + + +// Helper function used by the CHECK_EQ function when given int +// arguments. Should not be called directly. +inline void CheckEqualsHelper(const char* file, int line, + const char* expected_source, int expected, + const char* value_source, int value) { + if (expected != value) { + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", + expected_source, value_source, expected, value); + } +} + + +// Helper function used by the CHECK_EQ function when given int64_t +// arguments. Should not be called directly. +inline void CheckEqualsHelper(const char* file, int line, + const char* expected_source, + int64_t expected, + const char* value_source, + int64_t value) { + if (expected != value) { + // Print int64_t values in hex, as two int32s, + // to avoid platform-dependencies. + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n#" + " Expected: 0x%08x%08x\n# Found: 0x%08x%08x", + expected_source, value_source, + static_cast(expected >> 32), + static_cast(expected), + static_cast(value >> 32), + static_cast(value)); + } +} + + +// Helper function used by the CHECK_NE function when given int +// arguments. Should not be called directly. +inline void CheckNonEqualsHelper(const char* file, + int line, + const char* unexpected_source, + int unexpected, + const char* value_source, + int value) { + if (unexpected == value) { + V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i", + unexpected_source, value_source, value); + } +} + + +// Helper function used by the CHECK function when given string +// arguments. Should not be called directly. +inline void CheckEqualsHelper(const char* file, + int line, + const char* expected_source, + const char* expected, + const char* value_source, + const char* value) { + if ((expected == NULL && value != NULL) || + (expected != NULL && value == NULL) || + (expected != NULL && value != NULL && strcmp(expected, value) != 0)) { + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s", + expected_source, value_source, expected, value); + } +} + + +inline void CheckNonEqualsHelper(const char* file, + int line, + const char* expected_source, + const char* expected, + const char* value_source, + const char* value) { + if (expected == value || + (expected != NULL && value != NULL && strcmp(expected, value) == 0)) { + V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", + expected_source, value_source, value); + } +} + + +// Helper function used by the CHECK function when given pointer +// arguments. Should not be called directly. +inline void CheckEqualsHelper(const char* file, + int line, + const char* expected_source, + const void* expected, + const char* value_source, + const void* value) { + if (expected != value) { + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n# Expected: %p\n# Found: %p", + expected_source, value_source, + expected, value); + } +} + + +inline void CheckNonEqualsHelper(const char* file, + int line, + const char* expected_source, + const void* expected, + const char* value_source, + const void* value) { + if (expected == value) { + V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p", + expected_source, value_source, value); + } +} + + +// Helper function used by the CHECK function when given floating +// point arguments. Should not be called directly. +inline void CheckEqualsHelper(const char* file, + int line, + const char* expected_source, + double expected, + const char* value_source, + double value) { + // Force values to 64 bit memory to truncate 80 bit precision on IA32. + volatile double* exp = new double[1]; + *exp = expected; + volatile double* val = new double[1]; + *val = value; + if (*exp != *val) { + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", + expected_source, value_source, *exp, *val); + } + delete[] exp; + delete[] val; +} + + +inline void CheckNonEqualsHelper(const char* file, + int line, + const char* expected_source, + int64_t expected, + const char* value_source, + int64_t value) { + if (expected == value) { + V8_Fatal(file, line, + "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", + expected_source, value_source, expected, value); + } +} + + +inline void CheckNonEqualsHelper(const char* file, + int line, + const char* expected_source, + double expected, + const char* value_source, + double value) { + // Force values to 64 bit memory to truncate 80 bit precision on IA32. + volatile double* exp = new double[1]; + *exp = expected; + volatile double* val = new double[1]; + *val = value; + if (*exp == *val) { + V8_Fatal(file, line, + "CHECK_NE(%s, %s) failed\n# Value: %f", + expected_source, value_source, *val); + } + delete[] exp; + delete[] val; +} + + +#define CHECK_EQ(expected, value) CheckEqualsHelper(__FILE__, __LINE__, \ + #expected, expected, #value, value) + + +#define CHECK_NE(unexpected, value) CheckNonEqualsHelper(__FILE__, __LINE__, \ + #unexpected, unexpected, #value, value) + + +#define CHECK_GT(a, b) CHECK((a) > (b)) +#define CHECK_GE(a, b) CHECK((a) >= (b)) +#define CHECK_LT(a, b) CHECK((a) < (b)) +#define CHECK_LE(a, b) CHECK((a) <= (b)) + + +namespace v8 { +namespace base { + +// Exposed for making debugging easier (to see where your function is being +// called, just add a call to DumpBacktrace). +void DumpBacktrace(); + +} } // namespace v8::base + + +// The ASSERT macro is equivalent to CHECK except that it only +// generates code in debug builds. +#ifdef DEBUG +#define ASSERT_RESULT(expr) CHECK(expr) +#define ASSERT(condition) CHECK(condition) +#define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) +#define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) +#define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) +#define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) +#define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) +#else +#define ASSERT_RESULT(expr) (expr) +#define ASSERT(condition) ((void) 0) +#define ASSERT_EQ(v1, v2) ((void) 0) +#define ASSERT_NE(v1, v2) ((void) 0) +#define ASSERT_GE(v1, v2) ((void) 0) +#define ASSERT_LT(v1, v2) ((void) 0) +#define ASSERT_LE(v1, v2) ((void) 0) +#endif + +#define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) + +// "Extra checks" are lightweight checks that are enabled in some release +// builds. +#ifdef ENABLE_EXTRA_CHECKS +#define EXTRA_CHECK(condition) CHECK(condition) +#else +#define EXTRA_CHECK(condition) ((void) 0) +#endif + +#endif // V8_BASE_LOGGING_H_ diff --git a/src/base/macros.h b/src/base/macros.h index 381107b..cb5bf79 100644 --- a/src/base/macros.h +++ b/src/base/macros.h @@ -7,6 +7,7 @@ #include "include/v8stdint.h" #include "src/base/build_config.h" +#include "src/base/logging.h" // The expression OFFSET_OF(type, field) computes the byte-offset @@ -114,6 +115,14 @@ inline void USE(T) { } #define IS_POWER_OF_TWO(x) ((x) != 0 && (((x) & ((x) - 1)) == 0)) +// Returns true iff x is a power of 2. Cannot be used with the maximally +// negative value of the type T (the -1 overflows). +template +inline bool IsPowerOf2(T x) { + return IS_POWER_OF_TWO(x); +} + + // Define our own macros for writing 64-bit constants. This is less fragile // than defining __STDC_CONSTANT_MACROS before including , and it // works on compilers that don't have it (like MSVC). @@ -164,4 +173,77 @@ inline void USE(T) { } // write V8_2PART_UINT64_C(0x12345678,90123456); #define V8_2PART_UINT64_C(a, b) (((static_cast(a) << 32) + 0x##b##u)) + +// Compute the 0-relative offset of some absolute value x of type T. +// This allows conversion of Addresses and integral types into +// 0-relative int offsets. +template +inline intptr_t OffsetFrom(T x) { + return x - static_cast(0); +} + + +// Compute the absolute value of type T for some 0-relative offset x. +// This allows conversion of 0-relative int offsets into Addresses and +// integral types. +template +inline T AddressFrom(intptr_t x) { + return static_cast(static_cast(0) + x); +} + + +// Return the largest multiple of m which is <= x. +template +inline T RoundDown(T x, intptr_t m) { + ASSERT(IsPowerOf2(m)); + return AddressFrom(OffsetFrom(x) & -m); +} + + +// Return the smallest multiple of m which is >= x. +template +inline T RoundUp(T x, intptr_t m) { + return RoundDown(static_cast(x + m - 1), m); +} + + +// Increment a pointer until it has the specified alignment. +// This works like RoundUp, but it works correctly on pointer types where +// sizeof(*pointer) might not be 1. +template +T AlignUp(T pointer, size_t alignment) { + ASSERT(sizeof(pointer) == sizeof(uintptr_t)); + uintptr_t pointer_raw = reinterpret_cast(pointer); + return reinterpret_cast(RoundUp(pointer_raw, alignment)); +} + + +template +inline bool IsAligned(T value, U alignment) { + return (value & (alignment - 1)) == 0; +} + + +// Returns the smallest power of two which is >= x. If you pass in a +// number that is already a power of two, it is returned as is. +// Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., +// figure 3-3, page 48, where the function is called clp2. +inline uint32_t RoundUpToPowerOf2(uint32_t x) { + ASSERT(x <= 0x80000000u); + x = x - 1; + x = x | (x >> 1); + x = x | (x >> 2); + x = x | (x >> 4); + x = x | (x >> 8); + x = x | (x >> 16); + return x + 1; +} + + +inline uint32_t RoundDownToPowerOf2(uint32_t x) { + uint32_t rounded_up = RoundUpToPowerOf2(x); + if (rounded_up > x) return rounded_up >> 1; + return rounded_up; +} + #endif // V8_BASE_MACROS_H_ diff --git a/src/platform/condition-variable.cc b/src/base/platform/condition-variable.cc similarity index 98% rename from src/platform/condition-variable.cc rename to src/base/platform/condition-variable.cc index e180acd..b4e18b7 100644 --- a/src/platform/condition-variable.cc +++ b/src/base/platform/condition-variable.cc @@ -2,15 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/platform/condition-variable.h" +#include "src/base/platform/condition-variable.h" #include #include -#include "src/platform/time.h" +#include "src/base/platform/time.h" namespace v8 { -namespace internal { +namespace base { #if V8_OS_POSIX @@ -319,4 +319,4 @@ bool ConditionVariable::WaitFor(Mutex* mutex, const TimeDelta& rel_time) { #endif // V8_OS_POSIX -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform/condition-variable.h b/src/base/platform/condition-variable.h similarity index 90% rename from src/platform/condition-variable.h rename to src/base/platform/condition-variable.h index 4e8724c..9855970 100644 --- a/src/platform/condition-variable.h +++ b/src/base/platform/condition-variable.h @@ -2,14 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_PLATFORM_CONDITION_VARIABLE_H_ -#define V8_PLATFORM_CONDITION_VARIABLE_H_ +#ifndef V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ +#define V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ #include "src/base/lazy-instance.h" -#include "src/platform/mutex.h" +#include "src/base/platform/mutex.h" namespace v8 { -namespace internal { +namespace base { // Forward declarations. class ConditionVariableEvent; @@ -107,12 +107,12 @@ class ConditionVariable V8_FINAL { // LockGuard lock_guard(&my_mutex); // my_condvar.Pointer()->Wait(&my_mutex); // } -typedef base::LazyStaticInstance< - ConditionVariable, base::DefaultConstructTrait, - base::ThreadSafeInitOnceTrait>::type LazyConditionVariable; +typedef LazyStaticInstance< + ConditionVariable, DefaultConstructTrait, + ThreadSafeInitOnceTrait>::type LazyConditionVariable; #define LAZY_CONDITION_VARIABLE_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_CONDITION_VARIABLE_H_ +#endif // V8_BASE_PLATFORM_CONDITION_VARIABLE_H_ diff --git a/src/platform/elapsed-timer.h b/src/base/platform/elapsed-timer.h similarity index 90% rename from src/platform/elapsed-timer.h rename to src/base/platform/elapsed-timer.h index 9955c3e..b525f05 100644 --- a/src/platform/elapsed-timer.h +++ b/src/base/platform/elapsed-timer.h @@ -2,16 +2,16 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_PLATFORM_ELAPSED_TIMER_H_ -#define V8_PLATFORM_ELAPSED_TIMER_H_ +#ifndef V8_BASE_PLATFORM_ELAPSED_TIMER_H_ +#define V8_BASE_PLATFORM_ELAPSED_TIMER_H_ -#include "src/checks.h" -#include "src/platform/time.h" +#include "src/base/logging.h" +#include "src/base/platform/time.h" namespace v8 { -namespace internal { +namespace base { -class ElapsedTimer V8_FINAL BASE_EMBEDDED { +class ElapsedTimer V8_FINAL { public: #ifdef DEBUG ElapsedTimer() : started_(false) {} @@ -92,6 +92,6 @@ class ElapsedTimer V8_FINAL BASE_EMBEDDED { #endif }; -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_ELAPSED_TIMER_H_ +#endif // V8_BASE_PLATFORM_ELAPSED_TIMER_H_ diff --git a/src/platform/mutex.cc b/src/base/platform/mutex.cc similarity index 97% rename from src/platform/mutex.cc rename to src/base/platform/mutex.cc index 014b41a..700093e 100644 --- a/src/platform/mutex.cc +++ b/src/base/platform/mutex.cc @@ -2,12 +2,12 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/platform/mutex.h" +#include "src/base/platform/mutex.h" #include namespace v8 { -namespace internal { +namespace base { #if V8_OS_POSIX @@ -188,4 +188,4 @@ bool RecursiveMutex::TryLock() { return true; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform/mutex.h b/src/base/platform/mutex.h similarity index 92% rename from src/platform/mutex.h rename to src/base/platform/mutex.h index 1e93468..256b1ce 100644 --- a/src/platform/mutex.h +++ b/src/base/platform/mutex.h @@ -2,21 +2,21 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_PLATFORM_MUTEX_H_ -#define V8_PLATFORM_MUTEX_H_ +#ifndef V8_BASE_PLATFORM_MUTEX_H_ +#define V8_BASE_PLATFORM_MUTEX_H_ #include "src/base/lazy-instance.h" #if V8_OS_WIN #include "src/base/win32-headers.h" #endif -#include "src/checks.h" +#include "src/base/logging.h" #if V8_OS_POSIX #include // NOLINT #endif namespace v8 { -namespace internal { +namespace base { // ---------------------------------------------------------------------------- // Mutex @@ -101,9 +101,8 @@ class Mutex V8_FINAL { // // Do something. // } // -typedef v8::base::LazyStaticInstance< - Mutex, v8::base::DefaultConstructTrait, - v8::base::ThreadSafeInitOnceTrait>::type LazyMutex; +typedef LazyStaticInstance, + ThreadSafeInitOnceTrait>::type LazyMutex; #define LAZY_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER @@ -182,9 +181,9 @@ class RecursiveMutex V8_FINAL { // // Do something. // } // -typedef v8::base::LazyStaticInstance< - RecursiveMutex, v8::base::DefaultConstructTrait, - v8::base::ThreadSafeInitOnceTrait>::type LazyRecursiveMutex; +typedef LazyStaticInstance, + ThreadSafeInitOnceTrait>::type LazyRecursiveMutex; #define LAZY_RECURSIVE_MUTEX_INITIALIZER LAZY_STATIC_INSTANCE_INITIALIZER @@ -211,6 +210,6 @@ class LockGuard V8_FINAL { DISALLOW_COPY_AND_ASSIGN(LockGuard); }; -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_MUTEX_H_ +#endif // V8_BASE_PLATFORM_MUTEX_H_ diff --git a/src/platform-cygwin.cc b/src/base/platform/platform-cygwin.cc similarity index 98% rename from src/platform-cygwin.cc rename to src/base/platform/platform-cygwin.cc index ac313b2..a351f13 100644 --- a/src/platform-cygwin.cc +++ b/src/base/platform/platform-cygwin.cc @@ -18,12 +18,12 @@ #undef MAP_TYPE +#include "src/base/macros.h" +#include "src/base/platform/platform.h" #include "src/base/win32-headers.h" -#include "src/platform.h" -#include "src/utils.h" namespace v8 { -namespace internal { +namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { @@ -328,4 +328,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-freebsd.cc b/src/base/platform/platform-freebsd.cc similarity index 98% rename from src/platform-freebsd.cc rename to src/base/platform/platform-freebsd.cc index 9e668a8..d7cd9d3 100644 --- a/src/platform-freebsd.cc +++ b/src/base/platform/platform-freebsd.cc @@ -29,12 +29,12 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { @@ -304,4 +304,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-linux.cc b/src/base/platform/platform-linux.cc similarity index 99% rename from src/platform-linux.cc rename to src/base/platform/platform-linux.cc index 9d7c8cd..9e1e899 100644 --- a/src/platform-linux.cc +++ b/src/base/platform/platform-linux.cc @@ -43,12 +43,12 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { #ifdef __arm__ @@ -429,4 +429,4 @@ bool VirtualMemory::HasLazyCommits() { return true; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-macos.cc b/src/base/platform/platform-macos.cc similarity index 98% rename from src/platform-macos.cc rename to src/base/platform/platform-macos.cc index 7b6609b..0e62881 100644 --- a/src/platform-macos.cc +++ b/src/base/platform/platform-macos.cc @@ -35,12 +35,12 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { // Constants used for mmap. @@ -307,4 +307,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-openbsd.cc b/src/base/platform/platform-openbsd.cc similarity index 98% rename from src/platform-openbsd.cc rename to src/base/platform/platform-openbsd.cc index c29ebde..8458065 100644 --- a/src/platform-openbsd.cc +++ b/src/base/platform/platform-openbsd.cc @@ -27,12 +27,12 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { @@ -335,4 +335,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-posix.cc b/src/base/platform/platform-posix.cc similarity index 98% rename from src/platform-posix.cc rename to src/base/platform/platform-posix.cc index bc9d8e2..8454213 100644 --- a/src/platform-posix.cc +++ b/src/base/platform/platform-posix.cc @@ -47,16 +47,16 @@ #include "src/base/lazy-instance.h" #include "src/base/macros.h" -#include "src/platform.h" -#include "src/platform/time.h" -#include "src/utils/random-number-generator.h" +#include "src/base/platform/platform.h" +#include "src/base/platform/time.h" +#include "src/base/utils/random-number-generator.h" #ifdef V8_FAST_TLS_SUPPORTED #include "src/base/atomicops.h" #endif namespace v8 { -namespace internal { +namespace base { namespace { @@ -199,7 +199,7 @@ void OS::Guard(void* address, const size_t size) { } -static base::LazyInstance::type +static LazyInstance::type platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; @@ -626,7 +626,7 @@ static pthread_key_t LocalKeyToPthreadKey(Thread::LocalStorageKey local_key) { #ifdef V8_FAST_TLS_SUPPORTED -static base::Atomic32 tls_base_offset_initialized = 0; +static Atomic32 tls_base_offset_initialized = 0; intptr_t kMacTlsBaseOffset = 0; // It's safe to do the initialization more that once, but it has to be @@ -662,7 +662,7 @@ static void InitializeTlsBaseOffset() { kMacTlsBaseOffset = 0; } - base::Release_Store(&tls_base_offset_initialized, 1); + Release_Store(&tls_base_offset_initialized, 1); } @@ -723,4 +723,4 @@ void Thread::SetThreadLocal(LocalStorageKey key, void* value) { } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-qnx.cc b/src/base/platform/platform-qnx.cc similarity index 98% rename from src/platform-qnx.cc rename to src/base/platform/platform-qnx.cc index bdf07d5..e4570f2 100644 --- a/src/platform-qnx.cc +++ b/src/base/platform/platform-qnx.cc @@ -31,12 +31,12 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { // 0 is never a valid thread id on Qnx since tids and pids share a // name space and pid 0 is reserved (see man 2 kill). @@ -371,4 +371,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-solaris.cc b/src/base/platform/platform-solaris.cc similarity index 98% rename from src/platform-solaris.cc rename to src/base/platform/platform-solaris.cc index 4803531..992a97b 100644 --- a/src/platform-solaris.cc +++ b/src/base/platform/platform-solaris.cc @@ -27,8 +27,8 @@ #undef MAP_TYPE -#include "src/platform.h" -#include "src/utils.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" // It seems there is a bug in some Solaris distributions (experienced in @@ -52,7 +52,7 @@ int signbit(double x) { #endif // signbit namespace v8 { -namespace internal { +namespace base { const char* OS::LocalTimezone(double time, TimezoneCache* cache) { @@ -276,4 +276,4 @@ bool VirtualMemory::HasLazyCommits() { return false; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform-win32.cc b/src/base/platform/platform-win32.cc similarity index 98% rename from src/platform-win32.cc rename to src/base/platform/platform-win32.cc index f89c107..b4f934e 100644 --- a/src/platform-win32.cc +++ b/src/base/platform/platform-win32.cc @@ -15,13 +15,17 @@ #endif // MINGW_HAS_SECURE_API #endif // __MINGW32__ +#ifdef _MSC_VER +#include +#endif + #include "src/base/win32-headers.h" #include "src/base/lazy-instance.h" -#include "src/platform.h" -#include "src/platform/time.h" -#include "src/utils.h" -#include "src/utils/random-number-generator.h" +#include "src/base/macros.h" +#include "src/base/platform/platform.h" +#include "src/base/platform/time.h" +#include "src/base/utils/random-number-generator.h" #ifdef _MSC_VER @@ -101,7 +105,7 @@ int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { #endif // __MINGW32__ namespace v8 { -namespace internal { +namespace base { namespace { @@ -715,7 +719,7 @@ size_t OS::AllocateAlignment() { } -static base::LazyInstance::type +static LazyInstance::type platform_random_number_generator = LAZY_INSTANCE_INITIALIZER; @@ -890,7 +894,7 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size, if (file_mapping == NULL) return NULL; // Map a view of the file into memory void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); - if (memory) MemMove(memory, initial, size); + if (memory) memmove(memory, initial, size); return new Win32MemoryMappedFile(file, file_mapping, memory, size); } @@ -1096,7 +1100,7 @@ static std::vector LoadSymbols( ok = _SymGetSearchPath(process_handle, buf, OS::kStackWalkMaxNameLen); if (!ok) { int err = GetLastError(); - PrintF("%d\n", err); + OS::Print("%d\n", err); return result; } @@ -1190,10 +1194,7 @@ int OS::NumberOfProcessorsOnline() { double OS::nan_value() { #ifdef _MSC_VER - // Positive Quiet NaN with no payload (aka. Indeterminate) has all bits - // in mask set, so value equals mask. - static const __int64 nanval = kQuietNaNMask; - return *reinterpret_cast(&nanval); + return std::numeric_limits::quiet_NaN(); #else // _MSC_VER return NAN; #endif // _MSC_VER @@ -1420,4 +1421,4 @@ void Thread::YieldCPU() { Sleep(0); } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform.h b/src/base/platform/platform.h similarity index 98% rename from src/platform.h rename to src/base/platform/platform.h index b7aca9d..b00581e 100644 --- a/src/platform.h +++ b/src/base/platform/platform.h @@ -18,16 +18,16 @@ // implementation and the overhead of virtual methods for performance // sensitive like mutex locking/unlocking. -#ifndef V8_PLATFORM_H_ -#define V8_PLATFORM_H_ +#ifndef V8_BASE_PLATFORM_PLATFORM_H_ +#define V8_BASE_PLATFORM_PLATFORM_H_ #include #include #include #include "src/base/build_config.h" -#include "src/platform/mutex.h" -#include "src/platform/semaphore.h" +#include "src/base/platform/mutex.h" +#include "src/base/platform/semaphore.h" #ifdef __sun # ifndef signbit @@ -38,14 +38,14 @@ int signbit(double x); #endif #if V8_OS_QNX -#include "src/qnx-math.h" +#include "src/base/qnx-math.h" #endif // Microsoft Visual C++ specific stuff. #if V8_LIBC_MSVCRT #include "src/base/win32-headers.h" -#include "src/win32-math.h" +#include "src/base/win32-math.h" int strncasecmp(const char* s1, const char* s2, int n); @@ -72,7 +72,7 @@ inline int lrint(double flt) { #endif // V8_LIBC_MSVCRT namespace v8 { -namespace internal { +namespace base { // ---------------------------------------------------------------------------- // Fast TLS support @@ -519,6 +519,6 @@ class Thread { DISALLOW_COPY_AND_ASSIGN(Thread); }; -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_H_ +#endif // V8_BASE_PLATFORM_PLATFORM_H_ diff --git a/src/platform/semaphore.cc b/src/base/platform/semaphore.cc similarity index 96% rename from src/platform/semaphore.cc rename to src/base/platform/semaphore.cc index 18264f4..577d641 100644 --- a/src/platform/semaphore.cc +++ b/src/base/platform/semaphore.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/platform/semaphore.h" +#include "src/base/platform/semaphore.h" #if V8_OS_MACOSX #include @@ -11,11 +11,11 @@ #include -#include "src/checks.h" -#include "src/platform/time.h" +#include "src/base/logging.h" +#include "src/base/platform/time.h" namespace v8 { -namespace internal { +namespace base { #if V8_OS_MACOSX @@ -188,4 +188,4 @@ bool Semaphore::WaitFor(const TimeDelta& rel_time) { #endif // V8_OS_MACOSX -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform/semaphore.h b/src/base/platform/semaphore.h similarity index 88% rename from src/platform/semaphore.h rename to src/base/platform/semaphore.h index 028af92..b3105e3 100644 --- a/src/platform/semaphore.h +++ b/src/base/platform/semaphore.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_PLATFORM_SEMAPHORE_H_ -#define V8_PLATFORM_SEMAPHORE_H_ +#ifndef V8_BASE_PLATFORM_SEMAPHORE_H_ +#define V8_BASE_PLATFORM_SEMAPHORE_H_ #include "src/base/lazy-instance.h" #if V8_OS_WIN @@ -17,7 +17,7 @@ #endif namespace v8 { -namespace internal { +namespace base { // Forward declarations. class TimeDelta; @@ -90,14 +90,12 @@ struct CreateSemaphoreTrait { template struct LazySemaphore { - typedef typename v8::base::LazyDynamicInstance< - Semaphore, - CreateSemaphoreTrait, - v8::base::ThreadSafeInitOnceTrait>::type type; + typedef typename LazyDynamicInstance, + ThreadSafeInitOnceTrait>::type type; }; #define LAZY_SEMAPHORE_INITIALIZER LAZY_DYNAMIC_INSTANCE_INITIALIZER -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_SEMAPHORE_H_ +#endif // V8_BASE_PLATFORM_SEMAPHORE_H_ diff --git a/src/platform/time.cc b/src/base/platform/time.cc similarity index 95% rename from src/platform/time.cc rename to src/base/platform/time.cc index 09b6f8a..f3442b5 100644 --- a/src/platform/time.cc +++ b/src/base/platform/time.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/platform/time.h" +#include "src/base/platform/time.h" #if V8_OS_POSIX #include @@ -17,12 +17,12 @@ #include "src/base/lazy-instance.h" #include "src/base/win32-headers.h" #endif -#include "src/checks.h" -#include "src/cpu.h" -#include "src/platform.h" +#include "src/base/cpu.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" namespace v8 { -namespace internal { +namespace base { TimeDelta TimeDelta::FromDays(int days) { return TimeDelta(days * Time::kMicrosecondsPerDay); @@ -194,8 +194,8 @@ class Clock V8_FINAL { }; -static base::LazyStaticInstance, - base::ThreadSafeInitOnceTrait>::type clock = +static LazyStaticInstance, + ThreadSafeInitOnceTrait>::type clock = LAZY_STATIC_INSTANCE_INITIALIZER; @@ -463,10 +463,9 @@ class RolloverProtectedTickClock V8_FINAL : public TickClock { }; -static base::LazyStaticInstance< - RolloverProtectedTickClock, - base::DefaultConstructTrait, - base::ThreadSafeInitOnceTrait>::type tick_clock = +static LazyStaticInstance, + ThreadSafeInitOnceTrait>::type tick_clock = LAZY_STATIC_INSTANCE_INITIALIZER; @@ -491,10 +490,9 @@ struct CreateHighResTickClockTrait { }; -static base::LazyDynamicInstance::type high_res_tick_clock = - LAZY_DYNAMIC_INSTANCE_INITIALIZER; +static LazyDynamicInstance::type high_res_tick_clock = + LAZY_DYNAMIC_INSTANCE_INITIALIZER; TimeTicks TimeTicks::Now() { @@ -567,4 +565,4 @@ bool TimeTicks::IsHighResolutionClockWorking() { #endif // V8_OS_WIN -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/platform/time.h b/src/base/platform/time.h similarity index 98% rename from src/platform/time.h rename to src/base/platform/time.h index d21e85d..aed03b1 100644 --- a/src/platform/time.h +++ b/src/base/platform/time.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_PLATFORM_TIME_H_ -#define V8_PLATFORM_TIME_H_ +#ifndef V8_BASE_PLATFORM_TIME_H_ +#define V8_BASE_PLATFORM_TIME_H_ #include #include @@ -19,7 +19,7 @@ struct timeval; } namespace v8 { -namespace internal { +namespace base { class Time; class TimeTicks; @@ -388,6 +388,6 @@ inline TimeTicks operator+(const TimeDelta& delta, const TimeTicks& ticks) { return ticks + delta; } -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_PLATFORM_TIME_H_ +#endif // V8_BASE_PLATFORM_TIME_H_ diff --git a/src/qnx-math.h b/src/base/qnx-math.h similarity index 77% rename from src/qnx-math.h rename to src/base/qnx-math.h index 8cf65d2..6ff18f8 100644 --- a/src/qnx-math.h +++ b/src/base/qnx-math.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_QNX_MATH_H_ -#define V8_QNX_MATH_H_ +#ifndef V8_BASE_QNX_MATH_H_ +#define V8_QBASE_NX_MATH_H_ #include @@ -16,4 +16,4 @@ using std::lrint; -#endif // V8_QNX_MATH_H_ +#endif // V8_BASE_QNX_MATH_H_ diff --git a/src/utils/random-number-generator.cc b/src/base/utils/random-number-generator.cc similarity index 95% rename from src/utils/random-number-generator.cc rename to src/base/utils/random-number-generator.cc index 3da6a5a..4db190d 100644 --- a/src/utils/random-number-generator.cc +++ b/src/base/utils/random-number-generator.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/utils/random-number-generator.h" +#include "src/base/utils/random-number-generator.h" #include #include @@ -10,11 +10,11 @@ #include #include "src/base/macros.h" -#include "src/platform/mutex.h" -#include "src/platform/time.h" +#include "src/base/platform/mutex.h" +#include "src/base/platform/time.h" namespace v8 { -namespace internal { +namespace base { static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; static RandomNumberGenerator::EntropySource entropy_source = NULL; @@ -128,4 +128,4 @@ void RandomNumberGenerator::SetSeed(int64_t seed) { seed_ = (seed ^ kMultiplier) & kMask; } -} } // namespace v8::internal +} } // namespace v8::base diff --git a/src/utils/random-number-generator.h b/src/base/utils/random-number-generator.h similarity index 94% rename from src/utils/random-number-generator.h rename to src/base/utils/random-number-generator.h index 6b077ee..5955d66 100644 --- a/src/utils/random-number-generator.h +++ b/src/base/utils/random-number-generator.h @@ -2,13 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef V8_UTILS_RANDOM_NUMBER_GENERATOR_H_ -#define V8_UTILS_RANDOM_NUMBER_GENERATOR_H_ +#ifndef V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_ +#define V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_ #include "src/base/macros.h" namespace v8 { -namespace internal { +namespace base { // ----------------------------------------------------------------------------- // RandomNumberGenerator @@ -84,6 +84,6 @@ class RandomNumberGenerator V8_FINAL { int64_t seed_; }; -} } // namespace v8::internal +} } // namespace v8::base -#endif // V8_UTILS_RANDOM_NUMBER_GENERATOR_H_ +#endif // V8_BASE_UTILS_RANDOM_NUMBER_GENERATOR_H_ diff --git a/src/win32-math.cc b/src/base/win32-math.cc similarity index 97% rename from src/win32-math.cc rename to src/base/win32-math.cc index 1e34b88..df70cd0 100644 --- a/src/win32-math.cc +++ b/src/base/win32-math.cc @@ -12,9 +12,9 @@ #include // Required for DBL_MAX and on Win32 for finite() #include // Required for INT_MAX etc. #include -#include "src/win32-math.h" +#include "src/base/win32-math.h" -#include "src/checks.h" +#include "src/base/logging.h" namespace std { diff --git a/src/win32-math.h b/src/base/win32-math.h similarity index 90% rename from src/win32-math.h rename to src/base/win32-math.h index 7b7cbc9..e1c0350 100644 --- a/src/win32-math.h +++ b/src/base/win32-math.h @@ -7,8 +7,8 @@ // semantics for these functions. // (http://www.opengroup.org/onlinepubs/000095399/) -#ifndef V8_WIN32_MATH_H_ -#define V8_WIN32_MATH_H_ +#ifndef V8_BASE_WIN32_MATH_H_ +#define V8_BASE_WIN32_MATH_H_ #ifndef _MSC_VER #error Wrong environment, expected MSVC. @@ -39,4 +39,4 @@ int signbit(double x); #endif // _MSC_VER < 1800 -#endif // V8_WIN32_MATH_H_ +#endif // V8_BASE_WIN32_MATH_H_ diff --git a/src/bignum-dtoa.cc b/src/bignum-dtoa.cc index 8860a9b..df911c7 100644 --- a/src/bignum-dtoa.cc +++ b/src/bignum-dtoa.cc @@ -5,7 +5,7 @@ #include #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" #include "src/bignum-dtoa.h" diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 8909e25..c240869 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -2361,8 +2361,8 @@ bool Genesis::InstallExtension(Isolate* isolate, // When an error is thrown during bootstrapping we automatically print // the line number at which this happened to the console in the isolate // error throwing functionality. - OS::PrintError("Error installing extension '%s'.\n", - current->extension()->name()); + base::OS::PrintError("Error installing extension '%s'.\n", + current->extension()->name()); isolate->clear_pending_exception(); } extension_states->set_state(current, INSTALLED); diff --git a/src/cached-powers.cc b/src/cached-powers.cc index 1b9fb03..04a7d95 100644 --- a/src/cached-powers.cc +++ b/src/cached-powers.cc @@ -7,8 +7,8 @@ #include #include "include/v8stdint.h" +#include "src/base/logging.h" #include "src/cached-powers.h" -#include "src/checks.h" #include "src/globals.h" namespace v8 { diff --git a/src/cached-powers.h b/src/cached-powers.h index 3b873a2..bfe3635 100644 --- a/src/cached-powers.h +++ b/src/cached-powers.h @@ -5,7 +5,7 @@ #ifndef V8_CACHED_POWERS_H_ #define V8_CACHED_POWERS_H_ -#include "src/checks.h" +#include "src/base/logging.h" #include "src/diy-fp.h" namespace v8 { diff --git a/src/checks.cc b/src/checks.cc index 23c9305..e2c2c07 100644 --- a/src/checks.cc +++ b/src/checks.cc @@ -4,15 +4,6 @@ #include "src/checks.h" -#if V8_LIBC_GLIBC || V8_OS_BSD -# include -# include -#elif V8_OS_QNX -# include -#endif // V8_LIBC_GLIBC || V8_OS_BSD -#include - -#include "src/platform.h" #include "src/v8.h" namespace v8 { @@ -20,75 +11,9 @@ namespace internal { intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } -// Attempts to dump a backtrace (if supported). -void DumpBacktrace() { -#if V8_LIBC_GLIBC || V8_OS_BSD - void* trace[100]; - int size = backtrace(trace, ARRAY_SIZE(trace)); - char** symbols = backtrace_symbols(trace, size); - OS::PrintError("\n==== C stack trace ===============================\n\n"); - if (size == 0) { - OS::PrintError("(empty)\n"); - } else if (symbols == NULL) { - OS::PrintError("(no symbols)\n"); - } else { - for (int i = 1; i < size; ++i) { - OS::PrintError("%2d: ", i); - char mangled[201]; - if (sscanf(symbols[i], "%*[^(]%*[(]%200[^)+]", mangled) == 1) { // NOLINT - int status; - size_t length; - char* demangled = abi::__cxa_demangle(mangled, NULL, &length, &status); - OS::PrintError("%s\n", demangled != NULL ? demangled : mangled); - free(demangled); - } else { - OS::PrintError("??\n"); - } - } - } - free(symbols); -#elif V8_OS_QNX - char out[1024]; - bt_accessor_t acc; - bt_memmap_t memmap; - bt_init_accessor(&acc, BT_SELF); - bt_load_memmap(&acc, &memmap); - bt_sprn_memmap(&memmap, out, sizeof(out)); - OS::PrintError(out); - bt_addr_t trace[100]; - int size = bt_get_backtrace(&acc, trace, ARRAY_SIZE(trace)); - OS::PrintError("\n==== C stack trace ===============================\n\n"); - if (size == 0) { - OS::PrintError("(empty)\n"); - } else { - bt_sprnf_addrs(&memmap, trace, size, const_cast("%a\n"), - out, sizeof(out), NULL); - OS::PrintError(out); - } - bt_unload_memmap(&memmap); - bt_release_accessor(&acc); -#endif // V8_LIBC_GLIBC || V8_OS_BSD -} - } } // namespace v8::internal -// Contains protection against recursive calls (faults while handling faults). -extern "C" void V8_Fatal(const char* file, int line, const char* format, ...) { - fflush(stdout); - fflush(stderr); - i::OS::PrintError("\n\n#\n# Fatal error in %s, line %d\n# ", file, line); - va_list arguments; - va_start(arguments, format); - i::OS::VPrintError(format, arguments); - va_end(arguments); - i::OS::PrintError("\n#\n"); - v8::internal::DumpBacktrace(); - fflush(stderr); - i::OS::Abort(); -} - - void CheckEqualsHelper(const char* file, int line, const char* expected_source, diff --git a/src/checks.h b/src/checks.h index dd7a395..ae50a96 100644 --- a/src/checks.h +++ b/src/checks.h @@ -5,30 +5,7 @@ #ifndef V8_CHECKS_H_ #define V8_CHECKS_H_ -#include - -#include "include/v8stdint.h" -#include "src/base/build_config.h" - -extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); - - -// The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during -// development, but they should not be relied on in the final product. -#ifdef DEBUG -#define FATAL(msg) \ - V8_Fatal(__FILE__, __LINE__, "%s", (msg)) -#define UNIMPLEMENTED() \ - V8_Fatal(__FILE__, __LINE__, "unimplemented code") -#define UNREACHABLE() \ - V8_Fatal(__FILE__, __LINE__, "unreachable code") -#else -#define FATAL(msg) \ - V8_Fatal("", 0, "%s", (msg)) -#define UNIMPLEMENTED() \ - V8_Fatal("", 0, "unimplemented code") -#define UNREACHABLE() ((void) 0) -#endif +#include "src/base/logging.h" // Simulator specific helpers. // We can't use USE_SIMULATOR here because it isn't defined yet. @@ -49,199 +26,6 @@ extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); #endif -// The CHECK macro checks that the given condition is true; if not, it -// prints a message to stderr and aborts. -#define CHECK(condition) do { \ - if (!(condition)) { \ - V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ - } \ - } while (0) - - -// Helper function used by the CHECK_EQ function when given int -// arguments. Should not be called directly. -inline void CheckEqualsHelper(const char* file, int line, - const char* expected_source, int expected, - const char* value_source, int value) { - if (expected != value) { - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", - expected_source, value_source, expected, value); - } -} - - -// Helper function used by the CHECK_EQ function when given int64_t -// arguments. Should not be called directly. -inline void CheckEqualsHelper(const char* file, int line, - const char* expected_source, - int64_t expected, - const char* value_source, - int64_t value) { - if (expected != value) { - // Print int64_t values in hex, as two int32s, - // to avoid platform-dependencies. - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n#" - " Expected: 0x%08x%08x\n# Found: 0x%08x%08x", - expected_source, value_source, - static_cast(expected >> 32), - static_cast(expected), - static_cast(value >> 32), - static_cast(value)); - } -} - - -// Helper function used by the CHECK_NE function when given int -// arguments. Should not be called directly. -inline void CheckNonEqualsHelper(const char* file, - int line, - const char* unexpected_source, - int unexpected, - const char* value_source, - int value) { - if (unexpected == value) { - V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i", - unexpected_source, value_source, value); - } -} - - -// Helper function used by the CHECK function when given string -// arguments. Should not be called directly. -inline void CheckEqualsHelper(const char* file, - int line, - const char* expected_source, - const char* expected, - const char* value_source, - const char* value) { - if ((expected == NULL && value != NULL) || - (expected != NULL && value == NULL) || - (expected != NULL && value != NULL && strcmp(expected, value) != 0)) { - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s", - expected_source, value_source, expected, value); - } -} - - -inline void CheckNonEqualsHelper(const char* file, - int line, - const char* expected_source, - const char* expected, - const char* value_source, - const char* value) { - if (expected == value || - (expected != NULL && value != NULL && strcmp(expected, value) == 0)) { - V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", - expected_source, value_source, value); - } -} - - -// Helper function used by the CHECK function when given pointer -// arguments. Should not be called directly. -inline void CheckEqualsHelper(const char* file, - int line, - const char* expected_source, - const void* expected, - const char* value_source, - const void* value) { - if (expected != value) { - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n# Expected: %p\n# Found: %p", - expected_source, value_source, - expected, value); - } -} - - -inline void CheckNonEqualsHelper(const char* file, - int line, - const char* expected_source, - const void* expected, - const char* value_source, - const void* value) { - if (expected == value) { - V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p", - expected_source, value_source, value); - } -} - - -// Helper function used by the CHECK function when given floating -// point arguments. Should not be called directly. -inline void CheckEqualsHelper(const char* file, - int line, - const char* expected_source, - double expected, - const char* value_source, - double value) { - // Force values to 64 bit memory to truncate 80 bit precision on IA32. - volatile double* exp = new double[1]; - *exp = expected; - volatile double* val = new double[1]; - *val = value; - if (*exp != *val) { - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", - expected_source, value_source, *exp, *val); - } - delete[] exp; - delete[] val; -} - - -inline void CheckNonEqualsHelper(const char* file, - int line, - const char* expected_source, - int64_t expected, - const char* value_source, - int64_t value) { - if (expected == value) { - V8_Fatal(file, line, - "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", - expected_source, value_source, expected, value); - } -} - - -inline void CheckNonEqualsHelper(const char* file, - int line, - const char* expected_source, - double expected, - const char* value_source, - double value) { - // Force values to 64 bit memory to truncate 80 bit precision on IA32. - volatile double* exp = new double[1]; - *exp = expected; - volatile double* val = new double[1]; - *val = value; - if (*exp == *val) { - V8_Fatal(file, line, - "CHECK_NE(%s, %s) failed\n# Value: %f", - expected_source, value_source, *val); - } - delete[] exp; - delete[] val; -} - - -#define CHECK_EQ(expected, value) CheckEqualsHelper(__FILE__, __LINE__, \ - #expected, expected, #value, value) - - -#define CHECK_NE(unexpected, value) CheckNonEqualsHelper(__FILE__, __LINE__, \ - #unexpected, unexpected, #value, value) - - -#define CHECK_GT(a, b) CHECK((a) > (b)) -#define CHECK_GE(a, b) CHECK((a) >= (b)) -#define CHECK_LT(a, b) CHECK((a) < (b)) -#define CHECK_LE(a, b) CHECK((a) <= (b)) - - #ifdef DEBUG #ifndef OPTIMIZED_DEBUG #define ENABLE_SLOW_ASSERTS 1 @@ -249,7 +33,14 @@ inline void CheckNonEqualsHelper(const char* file, #endif namespace v8 { + +class Value; +template class Handle; + namespace internal { + +intptr_t HeapObjectTagMask(); + #ifdef ENABLE_SLOW_ASSERTS #define SLOW_ASSERT(condition) \ CHECK(!v8::internal::FLAG_enable_slow_asserts || (condition)) @@ -259,41 +50,26 @@ extern bool FLAG_enable_slow_asserts; const bool FLAG_enable_slow_asserts = false; #endif -// Exposed for making debugging easier (to see where your function is being -// called, just add a call to DumpBacktrace). -void DumpBacktrace(); - } } // namespace v8::internal -// The ASSERT macro is equivalent to CHECK except that it only -// generates code in debug builds. -#ifdef DEBUG -#define ASSERT_RESULT(expr) CHECK(expr) -#define ASSERT(condition) CHECK(condition) -#define ASSERT_EQ(v1, v2) CHECK_EQ(v1, v2) -#define ASSERT_NE(v1, v2) CHECK_NE(v1, v2) -#define ASSERT_GE(v1, v2) CHECK_GE(v1, v2) -#define ASSERT_LT(v1, v2) CHECK_LT(v1, v2) -#define ASSERT_LE(v1, v2) CHECK_LE(v1, v2) -#else -#define ASSERT_RESULT(expr) (expr) -#define ASSERT(condition) ((void) 0) -#define ASSERT_EQ(v1, v2) ((void) 0) -#define ASSERT_NE(v1, v2) ((void) 0) -#define ASSERT_GE(v1, v2) ((void) 0) -#define ASSERT_LT(v1, v2) ((void) 0) -#define ASSERT_LE(v1, v2) ((void) 0) -#endif +void CheckNonEqualsHelper(const char* file, + int line, + const char* unexpected_source, + v8::Handle unexpected, + const char* value_source, + v8::Handle value); -#define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) +void CheckEqualsHelper(const char* file, + int line, + const char* expected_source, + v8::Handle expected, + const char* value_source, + v8::Handle value); -// "Extra checks" are lightweight checks that are enabled in some release -// builds. -#ifdef ENABLE_EXTRA_CHECKS -#define EXTRA_CHECK(condition) CHECK(condition) -#else -#define EXTRA_CHECK(condition) ((void) 0) -#endif +#define ASSERT_TAG_ALIGNED(address) \ + ASSERT((reinterpret_cast(address) & HeapObjectTagMask()) == 0) + +#define ASSERT_SIZE_TAG_ALIGNED(size) ASSERT((size & HeapObjectTagMask()) == 0) #endif // V8_CHECKS_H_ diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc index 05d4226..cce31d9 100644 --- a/src/code-stubs-hydrogen.cc +++ b/src/code-stubs-hydrogen.cc @@ -262,7 +262,7 @@ static Handle DoGenerateCode(Stub* stub) { ASSERT(!descriptor->stack_parameter_count().is_valid()); return stub->GenerateLightweightMissCode(); } - ElapsedTimer timer; + base::ElapsedTimer timer; if (FLAG_profile_hydrogen_code_stub_compilation) { timer.Start(); } diff --git a/src/compiler.cc b/src/compiler.cc index bf9d598..92f8c11 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -353,7 +353,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() { // performance of the hydrogen-based compiler. bool should_recompile = !info()->shared_info()->has_deoptimization_support(); if (should_recompile || FLAG_hydrogen_stats) { - ElapsedTimer timer; + base::ElapsedTimer timer; if (FLAG_hydrogen_stats) { timer.Start(); } @@ -1313,7 +1313,7 @@ bool CompilationPhase::ShouldProduceTraceOutput() const { : (FLAG_trace_hydrogen && info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); return (tracing_on && - OS::StrChr(const_cast(FLAG_trace_phase), name_[0]) != NULL); + base::OS::StrChr(const_cast(FLAG_trace_phase), name_[0]) != NULL); } } } // namespace v8::internal diff --git a/src/compiler.h b/src/compiler.h index fdb7900..3aa8458 100644 --- a/src/compiler.h +++ b/src/compiler.h @@ -584,9 +584,9 @@ class OptimizedCompileJob: public ZoneObject { HOptimizedGraphBuilder* graph_builder_; HGraph* graph_; LChunk* chunk_; - TimeDelta time_taken_to_create_graph_; - TimeDelta time_taken_to_optimize_; - TimeDelta time_taken_to_codegen_; + base::TimeDelta time_taken_to_create_graph_; + base::TimeDelta time_taken_to_optimize_; + base::TimeDelta time_taken_to_codegen_; Status last_status_; bool awaiting_install_; @@ -597,7 +597,7 @@ class OptimizedCompileJob: public ZoneObject { void RecordOptimizationStats(); struct Timer { - Timer(OptimizedCompileJob* job, TimeDelta* location) + Timer(OptimizedCompileJob* job, base::TimeDelta* location) : job_(job), location_(location) { ASSERT(location_ != NULL); timer_.Start(); @@ -608,8 +608,8 @@ class OptimizedCompileJob: public ZoneObject { } OptimizedCompileJob* job_; - ElapsedTimer timer_; - TimeDelta* location_; + base::ElapsedTimer timer_; + base::TimeDelta* location_; }; }; @@ -702,7 +702,7 @@ class CompilationPhase BASE_EMBEDDED { CompilationInfo* info_; Zone zone_; unsigned info_zone_start_allocation_size_; - ElapsedTimer timer_; + base::ElapsedTimer timer_; DISALLOW_COPY_AND_ASSIGN(CompilationPhase); }; diff --git a/src/conversions-inl.h b/src/conversions-inl.h index 4087bb8..6b69af0 100644 --- a/src/conversions-inl.h +++ b/src/conversions-inl.h @@ -14,9 +14,9 @@ // ---------------------------------------------------------------------------- // Extra POSIX/ANSI functions for Win32/MSVC. +#include "src/base/platform/platform.h" #include "src/conversions.h" #include "src/double.h" -#include "src/platform.h" #include "src/scanner.h" #include "src/strtod.h" diff --git a/src/conversions.h b/src/conversions.h index 0c76574..5a9f470 100644 --- a/src/conversions.h +++ b/src/conversions.h @@ -7,7 +7,7 @@ #include -#include "src/checks.h" +#include "src/base/logging.h" #include "src/handles.h" #include "src/objects.h" #include "src/utils.h" diff --git a/src/counters.cc b/src/counters.cc index 42b0574..7de25e9 100644 --- a/src/counters.cc +++ b/src/counters.cc @@ -4,9 +4,9 @@ #include "src/v8.h" +#include "src/base/platform/platform.h" #include "src/counters.h" #include "src/isolate.h" -#include "src/platform.h" namespace v8 { namespace internal { diff --git a/src/counters.h b/src/counters.h index f7ff36b..540bcbd 100644 --- a/src/counters.h +++ b/src/counters.h @@ -7,9 +7,9 @@ #include "include/v8.h" #include "src/allocation.h" +#include "src/base/platform/elapsed-timer.h" #include "src/globals.h" #include "src/objects.h" -#include "src/platform/elapsed-timer.h" namespace v8 { namespace internal { @@ -241,11 +241,11 @@ class HistogramTimer : public Histogram { // TODO(bmeurer): Remove this when HistogramTimerScope is fixed. #ifdef DEBUG - ElapsedTimer* timer() { return &timer_; } + base::ElapsedTimer* timer() { return &timer_; } #endif private: - ElapsedTimer timer_; + base::ElapsedTimer timer_; }; // Helper class for scoping a HistogramTimer. diff --git a/src/cpu-profiler.cc b/src/cpu-profiler.cc index 49a1d7a..54fec77 100644 --- a/src/cpu-profiler.cc +++ b/src/cpu-profiler.cc @@ -23,7 +23,7 @@ static const int kProfilerStackSize = 64 * KB; ProfilerEventsProcessor::ProfilerEventsProcessor( ProfileGenerator* generator, Sampler* sampler, - TimeDelta period) + base::TimeDelta period) : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), generator_(generator), sampler_(sampler), @@ -108,7 +108,7 @@ ProfilerEventsProcessor::SampleProcessingResult void ProfilerEventsProcessor::Run() { while (running_) { - ElapsedTimer timer; + base::ElapsedTimer timer; timer.Start(); // Keep processing existing events until we need to do next sample. do { @@ -373,7 +373,7 @@ void CpuProfiler::SetterCallbackEvent(Name* name, Address entry_point) { CpuProfiler::CpuProfiler(Isolate* isolate) : isolate_(isolate), - sampling_interval_(TimeDelta::FromMicroseconds( + sampling_interval_(base::TimeDelta::FromMicroseconds( FLAG_cpu_profiler_sampling_interval)), profiles_(new CpuProfilesCollection(isolate->heap())), generator_(NULL), @@ -387,7 +387,7 @@ CpuProfiler::CpuProfiler(Isolate* isolate, ProfileGenerator* test_generator, ProfilerEventsProcessor* test_processor) : isolate_(isolate), - sampling_interval_(TimeDelta::FromMicroseconds( + sampling_interval_(base::TimeDelta::FromMicroseconds( FLAG_cpu_profiler_sampling_interval)), profiles_(test_profiles), generator_(test_generator), @@ -402,7 +402,7 @@ CpuProfiler::~CpuProfiler() { } -void CpuProfiler::set_sampling_interval(TimeDelta value) { +void CpuProfiler::set_sampling_interval(base::TimeDelta value) { ASSERT(!is_profiling_); sampling_interval_ = value; } diff --git a/src/cpu-profiler.h b/src/cpu-profiler.h index f5f2014..d666255 100644 --- a/src/cpu-profiler.h +++ b/src/cpu-profiler.h @@ -7,8 +7,8 @@ #include "src/allocation.h" #include "src/base/atomicops.h" +#include "src/base/platform/time.h" #include "src/circular-queue.h" -#include "src/platform/time.h" #include "src/sampler.h" #include "src/unbound-queue.h" @@ -122,11 +122,11 @@ class CodeEventsContainer { // This class implements both the profile events processor thread and // methods called by event producers: VM and stack sampler threads. -class ProfilerEventsProcessor : public Thread { +class ProfilerEventsProcessor : public base::Thread { public: ProfilerEventsProcessor(ProfileGenerator* generator, Sampler* sampler, - TimeDelta period); + base::TimeDelta period); virtual ~ProfilerEventsProcessor() {} // Thread control. @@ -165,7 +165,7 @@ class ProfilerEventsProcessor : public Thread { Sampler* sampler_; bool running_; // Sampling period in microseconds. - const TimeDelta period_; + const base::TimeDelta period_; UnboundQueue events_buffer_; static const size_t kTickSampleBufferSize = 1 * MB; static const size_t kTickSampleQueueLength = @@ -200,7 +200,7 @@ class CpuProfiler : public CodeEventListener { virtual ~CpuProfiler(); - void set_sampling_interval(TimeDelta value); + void set_sampling_interval(base::TimeDelta value); void StartProfiling(const char* title, bool record_samples = false); void StartProfiling(String* title, bool record_samples); CpuProfile* StopProfiling(const char* title); @@ -259,7 +259,7 @@ class CpuProfiler : public CodeEventListener { void LogBuiltins(); Isolate* isolate_; - TimeDelta sampling_interval_; + base::TimeDelta sampling_interval_; CpuProfilesCollection* profiles_; ProfileGenerator* generator_; ProfilerEventsProcessor* processor_; diff --git a/src/d8.cc b/src/d8.cc index c8a8039..8bdf26f 100644 --- a/src/d8.cc +++ b/src/d8.cc @@ -37,12 +37,12 @@ #ifndef V8_SHARED #include "src/api.h" -#include "src/checks.h" -#include "src/cpu.h" +#include "src/base/cpu.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" #include "src/d8-debug.h" #include "src/debug.h" #include "src/natives.h" -#include "src/platform.h" #include "src/v8.h" #endif // !V8_SHARED @@ -134,11 +134,12 @@ Handle DumbLineEditor::Prompt(const char* prompt) { #ifndef V8_SHARED CounterMap* Shell::counter_map_; -i::OS::MemoryMappedFile* Shell::counters_file_ = NULL; +base::OS::MemoryMappedFile* Shell::counters_file_ = NULL; CounterCollection Shell::local_counters_; CounterCollection* Shell::counters_ = &local_counters_; -i::Mutex Shell::context_mutex_; -const i::TimeTicks Shell::kInitialTicks = i::TimeTicks::HighResolutionNow(); +base::Mutex Shell::context_mutex_; +const base::TimeTicks Shell::kInitialTicks = + base::TimeTicks::HighResolutionNow(); Persistent Shell::utility_context_; #endif // !V8_SHARED @@ -299,7 +300,8 @@ void Shell::PerformanceNow(const v8::FunctionCallbackInfo& args) { args.GetReturnValue().Set(heap->synthetic_time()); } else { - i::TimeDelta delta = i::TimeTicks::HighResolutionNow() - kInitialTicks; + base::TimeDelta delta = + base::TimeTicks::HighResolutionNow() - kInitialTicks; args.GetReturnValue().Set(delta.InMillisecondsF()); } } @@ -675,7 +677,7 @@ Counter* CounterCollection::GetNextCounter() { void Shell::MapCounters(const char* name) { - counters_file_ = i::OS::MemoryMappedFile::create( + counters_file_ = base::OS::MemoryMappedFile::create( name, sizeof(CounterCollection), &local_counters_); void* memory = (counters_file_ == NULL) ? NULL : counters_file_->memory(); @@ -918,7 +920,7 @@ void Shell::InitializeDebugger(Isolate* isolate) { Local Shell::CreateEvaluationContext(Isolate* isolate) { #ifndef V8_SHARED // This needs to be a critical section since this is not thread-safe - i::LockGuard lock_guard(&context_mutex_); + base::LockGuard lock_guard(&context_mutex_); #endif // !V8_SHARED // Initialize the global objects Handle global_template = CreateGlobalTemplate(isolate); @@ -1188,12 +1190,12 @@ Handle SourceGroup::ReadFile(Isolate* isolate, const char* name) { #ifndef V8_SHARED -i::Thread::Options SourceGroup::GetThreadOptions() { +base::Thread::Options SourceGroup::GetThreadOptions() { // On some systems (OSX 10.6) the stack size default is 0.5Mb or less // which is not enough to parse the big literal expressions used in tests. // The stack size should be at least StackGuard::kLimitSize + some // OS-specific padding for thread startup code. 2Mbytes seems to be enough. - return i::Thread::Options("IsolateThread", 2 * MB); + return base::Thread::Options("IsolateThread", 2 * MB); } @@ -1563,9 +1565,9 @@ int Shell::Main(int argc, char* argv[]) { Isolate* isolate = Isolate::New(); #ifndef V8_SHARED v8::ResourceConstraints constraints; - constraints.ConfigureDefaults(i::OS::TotalPhysicalMemory(), - i::OS::MaxVirtualMemory(), - i::OS::NumberOfProcessorsOnline()); + constraints.ConfigureDefaults(base::OS::TotalPhysicalMemory(), + base::OS::MaxVirtualMemory(), + base::OS::NumberOfProcessorsOnline()); v8::SetResourceConstraints(isolate, &constraints); #endif DumbLineEditor dumb_line_editor(isolate); diff --git a/src/d8.h b/src/d8.h index 4244a5f..53a9e1c 100644 --- a/src/d8.h +++ b/src/d8.h @@ -141,10 +141,10 @@ class SourceGroup { void WaitForThread(); private: - class IsolateThread : public i::Thread { + class IsolateThread : public base::Thread { public: explicit IsolateThread(SourceGroup* group) - : i::Thread(GetThreadOptions()), group_(group) {} + : base::Thread(GetThreadOptions()), group_(group) {} virtual void Run() { group_->ExecuteInThread(); @@ -154,12 +154,12 @@ class SourceGroup { SourceGroup* group_; }; - static i::Thread::Options GetThreadOptions(); + static base::Thread::Options GetThreadOptions(); void ExecuteInThread(); - i::Semaphore next_semaphore_; - i::Semaphore done_semaphore_; - i::Thread* thread_; + base::Semaphore next_semaphore_; + base::Semaphore done_semaphore_; + base::Thread* thread_; #endif // !V8_SHARED void ExitShell(int exit_code); @@ -367,9 +367,9 @@ class Shell : public i::AllStatic { // don't want to store the stats in a memory-mapped file static CounterCollection local_counters_; static CounterCollection* counters_; - static i::OS::MemoryMappedFile* counters_file_; - static i::Mutex context_mutex_; - static const i::TimeTicks kInitialTicks; + static base::OS::MemoryMappedFile* counters_file_; + static base::Mutex context_mutex_; + static const base::TimeTicks kInitialTicks; static Counter* GetCounter(const char* name, bool is_histogram); static void InstallUtilityScript(Isolate* isolate); diff --git a/src/date.cc b/src/date.cc index 3425ce2..4a3d4b3 100644 --- a/src/date.cc +++ b/src/date.cc @@ -40,7 +40,7 @@ void DateCache::ResetDateCache() { after_ = &dst_[1]; local_offset_ms_ = kInvalidLocalOffsetInMs; ymd_valid_ = false; - OS::ClearTimezoneCache(tz_cache_); + base::OS::ClearTimezoneCache(tz_cache_); } diff --git a/src/date.h b/src/date.h index 89ae641..812647b 100644 --- a/src/date.h +++ b/src/date.h @@ -6,8 +6,8 @@ #define V8_DATE_H_ #include "src/allocation.h" +#include "src/base/platform/platform.h" #include "src/globals.h" -#include "src/platform.h" namespace v8 { @@ -39,12 +39,12 @@ class DateCache { // It is an invariant of DateCache that cache stamp is non-negative. static const int kInvalidStamp = -1; - DateCache() : stamp_(0), tz_cache_(OS::CreateTimezoneCache()) { + DateCache() : stamp_(0), tz_cache_(base::OS::CreateTimezoneCache()) { ResetDateCache(); } virtual ~DateCache() { - OS::DisposeTimezoneCache(tz_cache_); + base::OS::DisposeTimezoneCache(tz_cache_); tz_cache_ = NULL; } @@ -93,7 +93,7 @@ class DateCache { if (time_ms < 0 || time_ms > kMaxEpochTimeInMs) { time_ms = EquivalentTime(time_ms); } - return OS::LocalTimezone(static_cast(time_ms), tz_cache_); + return base::OS::LocalTimezone(static_cast(time_ms), tz_cache_); } // ECMA 262 - 15.9.5.26 @@ -162,11 +162,12 @@ class DateCache { // These functions are virtual so that we can override them when testing. virtual int GetDaylightSavingsOffsetFromOS(int64_t time_sec) { double time_ms = static_cast(time_sec * 1000); - return static_cast(OS::DaylightSavingsOffset(time_ms, tz_cache_)); + return static_cast( + base::OS::DaylightSavingsOffset(time_ms, tz_cache_)); } virtual int GetLocalOffsetFromOS() { - double offset = OS::LocalTimeOffset(tz_cache_); + double offset = base::OS::LocalTimeOffset(tz_cache_); ASSERT(offset < kInvalidLocalOffsetInMs); return static_cast(offset); } @@ -234,7 +235,7 @@ class DateCache { int ymd_month_; int ymd_day_; - TimezoneCache* tz_cache_; + base::TimezoneCache* tz_cache_; }; } } // namespace v8::internal diff --git a/src/debug.cc b/src/debug.cc index a081127..94fdb47 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -3351,13 +3351,13 @@ LockingCommandMessageQueue::LockingCommandMessageQueue(Logger* logger, int size) bool LockingCommandMessageQueue::IsEmpty() const { - LockGuard lock_guard(&mutex_); + base::LockGuard lock_guard(&mutex_); return queue_.IsEmpty(); } CommandMessage LockingCommandMessageQueue::Get() { - LockGuard lock_guard(&mutex_); + base::LockGuard lock_guard(&mutex_); CommandMessage result = queue_.Get(); logger_->DebugEvent("Get", result.text()); return result; @@ -3365,14 +3365,14 @@ CommandMessage LockingCommandMessageQueue::Get() { void LockingCommandMessageQueue::Put(const CommandMessage& message) { - LockGuard lock_guard(&mutex_); + base::LockGuard lock_guard(&mutex_); queue_.Put(message); logger_->DebugEvent("Put", message.text()); } void LockingCommandMessageQueue::Clear() { - LockGuard lock_guard(&mutex_); + base::LockGuard lock_guard(&mutex_); queue_.Clear(); } diff --git a/src/debug.h b/src/debug.h index cfd7059..f5a19d1 100644 --- a/src/debug.h +++ b/src/debug.h @@ -8,13 +8,13 @@ #include "src/allocation.h" #include "src/arguments.h" #include "src/assembler.h" +#include "src/base/platform/platform.h" #include "src/execution.h" #include "src/factory.h" #include "src/flags.h" #include "src/frames-inl.h" #include "src/hashmap.h" #include "src/liveedit.h" -#include "src/platform.h" #include "src/string-stream.h" #include "src/v8threads.h" @@ -328,7 +328,7 @@ class LockingCommandMessageQueue BASE_EMBEDDED { private: Logger* logger_; CommandMessageQueue queue_; - mutable Mutex mutex_; + mutable base::Mutex mutex_; DISALLOW_COPY_AND_ASSIGN(LockingCommandMessageQueue); }; @@ -584,7 +584,7 @@ class Debug { v8::Debug::MessageHandler message_handler_; static const int kQueueInitialSize = 4; - Semaphore command_received_; // Signaled for each command received. + base::Semaphore command_received_; // Signaled for each command received. LockingCommandMessageQueue command_queue_; LockingCommandMessageQueue event_command_queue_; diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index d21e1c3..08fb148 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -19,7 +19,7 @@ namespace internal { static MemoryChunk* AllocateCodeChunk(MemoryAllocator* allocator) { return allocator->AllocateChunk(Deoptimizer::GetMaxDeoptTableSize(), - OS::CommitPageSize(), + base::OS::CommitPageSize(), #if defined(__native_client__) // The Native Client port of V8 uses an interpreter, // so code pages don't need PROT_EXEC. @@ -101,7 +101,7 @@ static const int kDeoptTableMaxEpilogueCodeSize = 2 * KB; size_t Deoptimizer::GetMaxDeoptTableSize() { int entries_size = Deoptimizer::kMaxNumberOfEntries * Deoptimizer::table_entry_size_; - int commit_page_size = static_cast(OS::CommitPageSize()); + int commit_page_size = static_cast(base::OS::CommitPageSize()); int page_count = ((kDeoptTableMaxEpilogueCodeSize + entries_size - 1) / commit_page_size) + 1; return static_cast(commit_page_size * page_count); @@ -739,7 +739,7 @@ void Deoptimizer::DoComputeOutputFrames() { compiled_code_->kind() == Code::OPTIMIZED_FUNCTION) { LOG(isolate(), CodeDeoptEvent(compiled_code_)); } - ElapsedTimer timer; + base::ElapsedTimer timer; // Determine basic deoptimization information. The optimized frame is // described by the input data. @@ -2780,7 +2780,7 @@ void Deoptimizer::EnsureCodeForDeoptimizationEntry(Isolate* isolate, chunk->CommitArea(desc.instr_size); CopyBytes(chunk->area_start(), desc.buffer, static_cast(desc.instr_size)); - CPU::FlushICache(chunk->area_start(), desc.instr_size); + CpuFeatures::FlushICache(chunk->area_start(), desc.instr_size); data->deopt_entry_code_entries_[type] = entry_count; } diff --git a/src/diy-fp.cc b/src/diy-fp.cc index 60147ed..cdad2a8 100644 --- a/src/diy-fp.cc +++ b/src/diy-fp.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/diy-fp.h" #include "src/globals.h" diff --git a/src/dtoa.cc b/src/dtoa.cc index 949e76b..c50d364 100644 --- a/src/dtoa.cc +++ b/src/dtoa.cc @@ -5,7 +5,7 @@ #include #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" #include "src/dtoa.h" diff --git a/src/elements-kind.h b/src/elements-kind.h index cdd928b..f3b3925 100644 --- a/src/elements-kind.h +++ b/src/elements-kind.h @@ -5,7 +5,7 @@ #ifndef V8_ELEMENTS_KIND_H_ #define V8_ELEMENTS_KIND_H_ -#include "src/v8checks.h" +#include "src/checks.h" namespace v8 { namespace internal { diff --git a/src/extensions/free-buffer-extension.cc b/src/extensions/free-buffer-extension.cc index ffba655..e8c7732 100644 --- a/src/extensions/free-buffer-extension.cc +++ b/src/extensions/free-buffer-extension.cc @@ -3,7 +3,8 @@ // found in the LICENSE file. #include "src/extensions/free-buffer-extension.h" -#include "src/platform.h" + +#include "src/base/platform/platform.h" #include "src/v8.h" namespace v8 { diff --git a/src/extensions/gc-extension.cc b/src/extensions/gc-extension.cc index e3c2b1d..74b7481 100644 --- a/src/extensions/gc-extension.cc +++ b/src/extensions/gc-extension.cc @@ -3,7 +3,8 @@ // found in the LICENSE file. #include "src/extensions/gc-extension.h" -#include "src/platform.h" + +#include "src/base/platform/platform.h" namespace v8 { namespace internal { diff --git a/src/fast-dtoa.cc b/src/fast-dtoa.cc index 919023c..ce12412 100644 --- a/src/fast-dtoa.cc +++ b/src/fast-dtoa.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" #include "src/fast-dtoa.h" diff --git a/src/fixed-dtoa.cc b/src/fixed-dtoa.cc index 4541e85..1163855 100644 --- a/src/fixed-dtoa.cc +++ b/src/fixed-dtoa.cc @@ -5,7 +5,7 @@ #include #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" #include "src/double.h" diff --git a/src/flags.cc b/src/flags.cc index 53942aa..2b5e9c6 100644 --- a/src/flags.cc +++ b/src/flags.cc @@ -8,7 +8,7 @@ #include "src/v8.h" #include "src/assembler.h" -#include "src/platform.h" +#include "src/base/platform/platform.h" #include "src/smart-pointers.h" #include "src/string-stream.h" diff --git a/src/gdb-jit.cc b/src/gdb-jit.cc index 09da388..e8fb072 100644 --- a/src/gdb-jit.cc +++ b/src/gdb-jit.cc @@ -5,6 +5,7 @@ #ifdef ENABLE_GDB_JIT_INTERFACE #include "src/v8.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/compiler.h" #include "src/frames-inl.h" @@ -13,7 +14,6 @@ #include "src/global-handles.h" #include "src/messages.h" #include "src/natives.h" -#include "src/platform.h" #include "src/scopes.h" namespace v8 { @@ -2032,7 +2032,7 @@ static void AddUnwindInfo(CodeDescription* desc) { } -static LazyMutex mutex = LAZY_MUTEX_INITIALIZER; +static base::LazyMutex mutex = LAZY_MUTEX_INITIALIZER; void GDBJITInterface::AddCode(const char* name, @@ -2042,7 +2042,7 @@ void GDBJITInterface::AddCode(const char* name, CompilationInfo* info) { if (!FLAG_gdbjit) return; - LockGuard lock_guard(mutex.Pointer()); + base::LockGuard lock_guard(mutex.Pointer()); DisallowHeapAllocation no_gc; HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); @@ -2128,7 +2128,7 @@ void GDBJITInterface::AddCode(GDBJITInterface::CodeTag tag, Code* code) { void GDBJITInterface::RemoveCode(Code* code) { if (!FLAG_gdbjit) return; - LockGuard lock_guard(mutex.Pointer()); + base::LockGuard lock_guard(mutex.Pointer()); HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), false); @@ -2166,7 +2166,7 @@ void GDBJITInterface::RemoveCodeRange(Address start, Address end) { void GDBJITInterface::RegisterDetailedLineInfo(Code* code, GDBJITLineInfo* line_info) { - LockGuard lock_guard(mutex.Pointer()); + base::LockGuard lock_guard(mutex.Pointer()); ASSERT(!IsLineInfoTagged(line_info)); HashMap::Entry* e = GetEntries()->Lookup(code, HashForCodeObject(code), true); ASSERT(e->value == NULL); diff --git a/src/globals.h b/src/globals.h index 970a0f4..1ac0dcf 100644 --- a/src/globals.h +++ b/src/globals.h @@ -8,8 +8,8 @@ #include "include/v8stdint.h" #include "src/base/build_config.h" +#include "src/base/logging.h" #include "src/base/macros.h" -#include "src/checks.h" // Unfortunately, the INFINITY macro cannot be used with the '-pedantic' // warning flag and certain versions of GCC due to a bug: @@ -26,6 +26,13 @@ #endif namespace v8 { + +namespace base { +class Mutex; +class RecursiveMutex; +class VirtualMemory; +} + namespace internal { // Determine whether we are running in a simulated environment. @@ -239,10 +246,6 @@ const uint32_t kFreeListZapValue = 0xfeed1eaf; const int kCodeZapValue = 0xbadc0de; -// Number of bits to represent the page size for paged spaces. The value of 20 -// gives 1Mb bytes per page. -const int kPageSizeBits = 20; - // On Intel architecture, cache line size is 64 bytes. // On ARM it may be less (32 bytes), but as far this constant is // used for aligning data, it doesn't hurt to align on a greater value. @@ -311,9 +314,6 @@ class Variable; class RelocInfo; class Deserializer; class MessageLocation; -class VirtualMemory; -class Mutex; -class RecursiveMutex; typedef bool (*WeakSlotCallback)(Object** pointer); diff --git a/src/hashmap.h b/src/hashmap.h index d800f2f..39efd66 100644 --- a/src/hashmap.h +++ b/src/hashmap.h @@ -6,7 +6,7 @@ #define V8_HASHMAP_H_ #include "src/allocation.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" namespace v8 { diff --git a/src/heap-inl.h b/src/heap-inl.h index 162dac2..77538ca 100644 --- a/src/heap-inl.h +++ b/src/heap-inl.h @@ -7,13 +7,13 @@ #include +#include "src/base/platform/platform.h" #include "src/cpu-profiler.h" #include "src/heap.h" #include "src/heap-profiler.h" #include "src/isolate.h" #include "src/list-inl.h" #include "src/objects.h" -#include "src/platform.h" #include "src/store-buffer.h" #include "src/store-buffer-inl.h" diff --git a/src/heap-snapshot-generator.cc b/src/heap-snapshot-generator.cc index be970ee..097d5a5 100644 --- a/src/heap-snapshot-generator.cc +++ b/src/heap-snapshot-generator.cc @@ -83,21 +83,21 @@ void HeapEntry::SetIndexedReference(HeapGraphEdge::Type type, void HeapEntry::Print( const char* prefix, const char* edge_name, int max_depth, int indent) { STATIC_ASSERT(sizeof(unsigned) == sizeof(id())); - OS::Print("%6" V8PRIuPTR " @%6u %*c %s%s: ", - self_size(), id(), indent, ' ', prefix, edge_name); + base::OS::Print("%6" V8PRIuPTR " @%6u %*c %s%s: ", self_size(), id(), indent, + ' ', prefix, edge_name); if (type() != kString) { - OS::Print("%s %.40s\n", TypeAsString(), name_); + base::OS::Print("%s %.40s\n", TypeAsString(), name_); } else { - OS::Print("\""); + base::OS::Print("\""); const char* c = name_; while (*c && (c - name_) <= 40) { if (*c != '\n') - OS::Print("%c", *c); + base::OS::Print("%c", *c); else - OS::Print("\\n"); + base::OS::Print("\\n"); ++c; } - OS::Print("\"\n"); + base::OS::Print("\"\n"); } if (--max_depth == 0) return; Vector ch = children(); diff --git a/src/heap.cc b/src/heap.cc index c4cf04a..812fec1 100644 --- a/src/heap.cc +++ b/src/heap.cc @@ -7,6 +7,7 @@ #include "src/accessors.h" #include "src/api.h" #include "src/base/once.h" +#include "src/base/utils/random-number-generator.h" #include "src/bootstrapper.h" #include "src/codegen.h" #include "src/compilation-cache.h" @@ -27,7 +28,6 @@ #include "src/snapshot.h" #include "src/store-buffer.h" #include "src/utils.h" -#include "src/utils/random-number-generator.h" #include "src/v8threads.h" #include "src/vm-state-inl.h" @@ -2775,7 +2775,7 @@ void Heap::CreateInitialObjects() { set_minus_zero_value(*factory->NewHeapNumber(-0.0, TENURED)); ASSERT(std::signbit(minus_zero_value()->Number()) != 0); - set_nan_value(*factory->NewHeapNumber(OS::nan_value(), TENURED)); + set_nan_value(*factory->NewHeapNumber(base::OS::nan_value(), TENURED)); set_infinity_value(*factory->NewHeapNumber(V8_INFINITY, TENURED)); // The hole has not been created yet, but we want to put something @@ -5026,7 +5026,7 @@ void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { *stats->memory_allocator_capacity = isolate()->memory_allocator()->Size() + isolate()->memory_allocator()->Available(); - *stats->os_error = OS::GetLastError(); + *stats->os_error = base::OS::GetLastError(); isolate()->memory_allocator()->Available(); if (take_snapshot) { HeapIterator iterator(this); @@ -6006,7 +6006,7 @@ GCTracer::GCTracer(Heap* heap, gc_reason_(gc_reason), collector_reason_(collector_reason) { if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; - start_time_ = OS::TimeCurrentMillis(); + start_time_ = base::OS::TimeCurrentMillis(); start_object_size_ = heap_->SizeOfObjects(); start_memory_size_ = heap_->isolate()->memory_allocator()->Size(); @@ -6040,7 +6040,7 @@ GCTracer::~GCTracer() { bool first_gc = (heap_->last_gc_end_timestamp_ == 0); heap_->alive_after_last_gc_ = heap_->SizeOfObjects(); - heap_->last_gc_end_timestamp_ = OS::TimeCurrentMillis(); + heap_->last_gc_end_timestamp_ = base::OS::TimeCurrentMillis(); double time = heap_->last_gc_end_timestamp_ - start_time_; @@ -6387,11 +6387,12 @@ void Heap::ClearObjectStats(bool clear_last_time_stats) { } -static LazyMutex checkpoint_object_stats_mutex = LAZY_MUTEX_INITIALIZER; +static base::LazyMutex checkpoint_object_stats_mutex = LAZY_MUTEX_INITIALIZER; void Heap::CheckpointObjectStats() { - LockGuard lock_guard(checkpoint_object_stats_mutex.Pointer()); + base::LockGuard lock_guard( + checkpoint_object_stats_mutex.Pointer()); Counters* counters = isolate()->counters(); #define ADJUST_LAST_TIME_OBJECT_COUNT(name) \ counters->count_of_##name()->Increment( \ diff --git a/src/heap.h b/src/heap.h index 85af3c9..754b558 100644 --- a/src/heap.h +++ b/src/heap.h @@ -2146,7 +2146,7 @@ class Heap { MemoryChunk* chunks_queued_for_free_; - Mutex relocation_mutex_; + base::Mutex relocation_mutex_; int gc_callbacks_depth_; @@ -2526,12 +2526,12 @@ class GCTracer BASE_EMBEDDED { Scope(GCTracer* tracer, ScopeId scope) : tracer_(tracer), scope_(scope) { - start_time_ = OS::TimeCurrentMillis(); + start_time_ = base::OS::TimeCurrentMillis(); } ~Scope() { ASSERT(scope_ < kNumberOfScopes); // scope_ is unsigned. - tracer_->scopes_[scope_] += OS::TimeCurrentMillis() - start_time_; + tracer_->scopes_[scope_] += base::OS::TimeCurrentMillis() - start_time_; } private: diff --git a/src/hydrogen-bce.cc b/src/hydrogen-bce.cc index 5b13429..51ccf81 100644 --- a/src/hydrogen-bce.cc +++ b/src/hydrogen-bce.cc @@ -170,8 +170,8 @@ class BoundsCheckBbData: public ZoneObject { if (!keep_new_check) { if (FLAG_trace_bce) { - OS::Print("Eliminating check #%d after tightening\n", - new_check->id()); + base::OS::Print("Eliminating check #%d after tightening\n", + new_check->id()); } new_check->block()->graph()->isolate()->counters()-> bounds_checks_eliminated()->Increment(); @@ -180,8 +180,8 @@ class BoundsCheckBbData: public ZoneObject { HBoundsCheck* first_check = new_check == lower_check_ ? upper_check_ : lower_check_; if (FLAG_trace_bce) { - OS::Print("Moving second check #%d after first check #%d\n", - new_check->id(), first_check->id()); + base::OS::Print("Moving second check #%d after first check #%d\n", + new_check->id(), first_check->id()); } // The length is guaranteed to be live at first_check. ASSERT(new_check->length() == first_check->length()); @@ -283,8 +283,8 @@ class BoundsCheckBbData: public ZoneObject { original_check->ReplaceAllUsesWith(original_check->index()); original_check->SetOperandAt(0, tighter_check->index()); if (FLAG_trace_bce) { - OS::Print("Tightened check #%d with offset %d from #%d\n", - original_check->id(), new_offset, tighter_check->id()); + base::OS::Print("Tightened check #%d with offset %d from #%d\n", + original_check->id(), new_offset, tighter_check->id()); } } @@ -396,15 +396,15 @@ BoundsCheckBbData* HBoundsCheckEliminationPhase::PreProcessBlock( NULL); *data_p = bb_data_list; if (FLAG_trace_bce) { - OS::Print("Fresh bounds check data for block #%d: [%d]\n", - bb->block_id(), offset); + base::OS::Print("Fresh bounds check data for block #%d: [%d]\n", + bb->block_id(), offset); } } else if (data->OffsetIsCovered(offset)) { bb->graph()->isolate()->counters()-> bounds_checks_eliminated()->Increment(); if (FLAG_trace_bce) { - OS::Print("Eliminating bounds check #%d, offset %d is covered\n", - check->id(), offset); + base::OS::Print("Eliminating bounds check #%d, offset %d is covered\n", + check->id(), offset); } check->DeleteAndReplaceWith(check->ActualValue()); } else if (data->BasicBlock() == bb) { @@ -439,8 +439,8 @@ BoundsCheckBbData* HBoundsCheckEliminationPhase::PreProcessBlock( bb_data_list, data); if (FLAG_trace_bce) { - OS::Print("Updated bounds check data for block #%d: [%d - %d]\n", - bb->block_id(), new_lower_offset, new_upper_offset); + base::OS::Print("Updated bounds check data for block #%d: [%d - %d]\n", + bb->block_id(), new_lower_offset, new_upper_offset); } table_.Insert(key, bb_data_list, zone()); } diff --git a/src/hydrogen-gvn.cc b/src/hydrogen-gvn.cc index e6f1ae9..829a0bb 100644 --- a/src/hydrogen-gvn.cc +++ b/src/hydrogen-gvn.cc @@ -98,7 +98,7 @@ class HSideEffectMap V8_FINAL BASE_EMBEDDED { void TraceGVN(const char* msg, ...) { va_list arguments; va_start(arguments, msg); - OS::VPrint(msg, arguments); + base::OS::VPrint(msg, arguments); va_end(arguments); } diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 31cd9cc..9209b88 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2954,7 +2954,7 @@ Maybe HConstant::CopyToTruncatedNumber(Zone* zone) { res = handle->BooleanValue() ? new(zone) HConstant(1) : new(zone) HConstant(0); } else if (handle->IsUndefined()) { - res = new(zone) HConstant(OS::nan_value()); + res = new(zone) HConstant(base::OS::nan_value()); } else if (handle->IsNull()) { res = new(zone) HConstant(0); } @@ -4222,7 +4222,7 @@ HInstruction* HUnaryMathOperation::New( if (!constant->HasNumberValue()) break; double d = constant->DoubleValue(); if (std::isnan(d)) { // NaN poisons everything. - return H_CONSTANT_DOUBLE(OS::nan_value()); + return H_CONSTANT_DOUBLE(base::OS::nan_value()); } if (std::isinf(d)) { // +Infinity and -Infinity. switch (op) { @@ -4230,7 +4230,7 @@ HInstruction* HUnaryMathOperation::New( return H_CONSTANT_DOUBLE((d > 0.0) ? d : 0.0); case kMathLog: case kMathSqrt: - return H_CONSTANT_DOUBLE((d > 0.0) ? d : OS::nan_value()); + return H_CONSTANT_DOUBLE((d > 0.0) ? d : base::OS::nan_value()); case kMathPowHalf: case kMathAbs: return H_CONSTANT_DOUBLE((d > 0.0) ? d : -d); @@ -4325,7 +4325,8 @@ HInstruction* HPower::New(Zone* zone, if (c_left->HasNumberValue() && c_right->HasNumberValue()) { double result = power_helper(c_left->DoubleValue(), c_right->DoubleValue()); - return H_CONSTANT_DOUBLE(std::isnan(result) ? OS::nan_value() : result); + return H_CONSTANT_DOUBLE(std::isnan(result) ? base::OS::nan_value() + : result); } } return new(zone) HPower(left, right); @@ -4358,7 +4359,7 @@ HInstruction* HMathMinMax::New( } } // All comparisons failed, must be NaN. - return H_CONSTANT_DOUBLE(OS::nan_value()); + return H_CONSTANT_DOUBLE(base::OS::nan_value()); } } return new(zone) HMathMinMax(context, left, right, op); diff --git a/src/hydrogen-range-analysis.cc b/src/hydrogen-range-analysis.cc index 64d1dc0..cb94467 100644 --- a/src/hydrogen-range-analysis.cc +++ b/src/hydrogen-range-analysis.cc @@ -26,7 +26,7 @@ void HRangeAnalysisPhase::TraceRange(const char* msg, ...) { if (FLAG_trace_range) { va_list arguments; va_start(arguments, msg); - OS::VPrint(msg, arguments); + base::OS::VPrint(msg, arguments); va_end(arguments); } } diff --git a/src/hydrogen.cc b/src/hydrogen.cc index ec5bb9b..0651e71 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -9954,7 +9954,7 @@ HInstruction* HOptimizedGraphBuilder::BuildStringCharCodeAt( int32_t i = c_index->NumberValueAsInteger32(); Handle s = c_string->StringValue(); if (i < 0 || i >= s->length()) { - return New(OS::nan_value()); + return New(base::OS::nan_value()); } return New(s->Get(i)); } @@ -12056,7 +12056,8 @@ void HTracer::TraceCompilation(CompilationInfo* info) { PrintStringProperty("name", CodeStub::MajorName(major_key, false)); PrintStringProperty("method", "stub"); } - PrintLongProperty("date", static_cast(OS::TimeCurrentMillis())); + PrintLongProperty("date", + static_cast(base::OS::TimeCurrentMillis())); } @@ -12303,7 +12304,7 @@ void HStatistics::Initialize(CompilationInfo* info) { void HStatistics::Print() { PrintF("Timing results:\n"); - TimeDelta sum; + base::TimeDelta sum; for (int i = 0; i < times_.length(); ++i) { sum += times_[i]; } @@ -12321,7 +12322,7 @@ void HStatistics::Print() { PrintF("----------------------------------------" "---------------------------------------\n"); - TimeDelta total = create_graph_ + optimize_graph_ + generate_code_; + base::TimeDelta total = create_graph_ + optimize_graph_ + generate_code_; PrintF("%32s %8.3f ms / %4.1f %% \n", "Create graph", create_graph_.InMillisecondsF(), @@ -12354,7 +12355,8 @@ void HStatistics::Print() { } -void HStatistics::SaveTiming(const char* name, TimeDelta time, unsigned size) { +void HStatistics::SaveTiming(const char* name, base::TimeDelta time, + unsigned size) { total_size_ += size; for (int i = 0; i < names_.length(); ++i) { if (strcmp(names_[i], name) == 0) { diff --git a/src/hydrogen.h b/src/hydrogen.h index 74c1903..851e692 100644 --- a/src/hydrogen.h +++ b/src/hydrogen.h @@ -2753,29 +2753,29 @@ class HStatistics V8_FINAL: public Malloced { void Initialize(CompilationInfo* info); void Print(); - void SaveTiming(const char* name, TimeDelta time, unsigned size); + void SaveTiming(const char* name, base::TimeDelta time, unsigned size); - void IncrementFullCodeGen(TimeDelta full_code_gen) { + void IncrementFullCodeGen(base::TimeDelta full_code_gen) { full_code_gen_ += full_code_gen; } - void IncrementSubtotals(TimeDelta create_graph, - TimeDelta optimize_graph, - TimeDelta generate_code) { + void IncrementSubtotals(base::TimeDelta create_graph, + base::TimeDelta optimize_graph, + base::TimeDelta generate_code) { create_graph_ += create_graph; optimize_graph_ += optimize_graph; generate_code_ += generate_code; } private: - List times_; + List times_; List names_; List sizes_; - TimeDelta create_graph_; - TimeDelta optimize_graph_; - TimeDelta generate_code_; + base::TimeDelta create_graph_; + base::TimeDelta optimize_graph_; + base::TimeDelta generate_code_; unsigned total_size_; - TimeDelta full_code_gen_; + base::TimeDelta full_code_gen_; double source_size_; }; @@ -2804,7 +2804,7 @@ class HTracer V8_FINAL : public Malloced { if (FLAG_trace_hydrogen_file == NULL) { SNPrintF(filename_, "hydrogen-%d-%d.cfg", - OS::GetCurrentProcessId(), + base::OS::GetCurrentProcessId(), isolate_id); } else { StrNCpy(filename_, FLAG_trace_hydrogen_file, filename_.length()); diff --git a/src/ia32/assembler-ia32-inl.h b/src/ia32/assembler-ia32-inl.h index 422e1fd..9531c69 100644 --- a/src/ia32/assembler-ia32-inl.h +++ b/src/ia32/assembler-ia32-inl.h @@ -39,7 +39,7 @@ #include "src/ia32/assembler-ia32.h" -#include "src/cpu.h" +#include "src/assembler.h" #include "src/debug.h" namespace v8 { @@ -58,30 +58,30 @@ void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { if (IsRuntimeEntry(rmode_) || IsCodeTarget(rmode_)) { int32_t* p = reinterpret_cast(pc_); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (rmode_ == CODE_AGE_SEQUENCE) { if (*pc_ == kCallOpcode) { int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { // Special handling of js_return when a break point is set (call // instruction has been inserted). int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (rmode_ == DEBUG_BREAK_SLOT && IsPatchedDebugBreakSlotSequence()) { // Special handling of a debug break slot when a break point is set (call // instruction has been inserted). int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (IsInternalReference(rmode_)) { // absolute code pointer inside code object moves with the code object. int32_t* p = reinterpret_cast(pc_); *p += delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } } @@ -144,7 +144,7 @@ void RelocInfo::set_target_object(Object* target, ASSERT(!target->IsConsString()); Memory::Object_at(pc_) = target; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && @@ -197,7 +197,7 @@ void RelocInfo::set_target_cell(Cell* cell, Address address = cell->address() + Cell::kValueOffset; Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { // TODO(1550) We are passing NULL as a slot because cell can never be on @@ -294,14 +294,14 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { visitor->VisitCodeTarget(this); } else if (mode == RelocInfo::CELL) { visitor->VisitCell(this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { visitor->VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { visitor->VisitCodeAgeSequence(this); } else if (((RelocInfo::IsJSReturn(mode) && @@ -321,14 +321,14 @@ void RelocInfo::Visit(Heap* heap) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { StaticVisitor::VisitEmbeddedPointer(heap, this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { StaticVisitor::VisitCodeTarget(heap, this); } else if (mode == RelocInfo::CELL) { StaticVisitor::VisitCell(heap, this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { StaticVisitor::VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { StaticVisitor::VisitCodeAgeSequence(heap, this); } else if (heap->isolate()->debug()->has_break_points() && @@ -473,7 +473,7 @@ void Assembler::set_target_address_at(Address pc, int32_t* p = reinterpret_cast(pc); *p = target - (pc + sizeof(int32_t)); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(p, sizeof(int32_t)); + CpuFeatures::FlushICache(p, sizeof(int32_t)); } } diff --git a/src/ia32/assembler-ia32.cc b/src/ia32/assembler-ia32.cc index 75cb6ed..6497ba6 100644 --- a/src/ia32/assembler-ia32.cc +++ b/src/ia32/assembler-ia32.cc @@ -38,6 +38,7 @@ #if V8_TARGET_ARCH_IA32 +#include "src/base/cpu.h" #include "src/disassembler.h" #include "src/macro-assembler.h" #include "src/serialize.h" @@ -49,7 +50,7 @@ namespace internal { // Implementation of CpuFeatures void CpuFeatures::ProbeImpl(bool cross_compile) { - CPU cpu; + base::CPU cpu; CHECK(cpu.has_sse2()); // SSE2 support is mandatory. CHECK(cpu.has_cmov()); // CMOV support is mandatory. @@ -112,7 +113,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count); + CpuFeatures::FlushICache(pc_, instruction_count); } diff --git a/src/ia32/code-stubs-ia32.h b/src/ia32/code-stubs-ia32.h index fb5565a..219186c 100644 --- a/src/ia32/code-stubs-ia32.h +++ b/src/ia32/code-stubs-ia32.h @@ -248,7 +248,7 @@ class RecordWriteStub: public PlatformCodeStub { break; } ASSERT(GetMode(stub) == mode); - CPU::FlushICache(stub->instruction_start(), 7); + CpuFeatures::FlushICache(stub->instruction_start(), 7); } private: diff --git a/src/ia32/codegen-ia32.cc b/src/ia32/codegen-ia32.cc index fbd5b89..1484b0f 100644 --- a/src/ia32/codegen-ia32.cc +++ b/src/ia32/codegen-ia32.cc @@ -37,7 +37,8 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { UnaryMathFunction CreateExpFunction() { if (!FLAG_fast_math) return &std::exp; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::exp; ExternalReference::InitializeMathExpData(); @@ -64,8 +65,8 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -73,9 +74,8 @@ UnaryMathFunction CreateExpFunction() { UnaryMathFunction CreateSqrtFunction() { size_t actual_size; // Allocate buffer in executable space. - byte* buffer = static_cast(OS::Allocate(1 * KB, - &actual_size, - true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::sqrt; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); // esp[1 * kPointerSize]: raw double input @@ -94,8 +94,8 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -189,7 +189,8 @@ class LabelConverter { MemMoveFunction CreateMemMoveFunction() { size_t actual_size; // Allocate buffer in executable space. - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return NULL; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); LabelConverter conv(buffer); @@ -504,8 +505,8 @@ MemMoveFunction CreateMemMoveFunction() { CodeDesc desc; masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); // TODO(jkummerow): It would be nice to register this code creation event // with the PROFILE / GDBJIT system. return FUNCTION_CAST(buffer); @@ -1005,7 +1006,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CPU::FlushICache(sequence, young_length); + CpuFeatures::FlushICache(sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length); diff --git a/src/ia32/cpu-ia32.cc b/src/ia32/cpu-ia32.cc index 7094f46..00c2043 100644 --- a/src/ia32/cpu-ia32.cc +++ b/src/ia32/cpu-ia32.cc @@ -12,13 +12,13 @@ #if V8_TARGET_ARCH_IA32 -#include "src/cpu.h" +#include "src/assembler.h" #include "src/macro-assembler.h" namespace v8 { namespace internal { -void CPU::FlushICache(void* start, size_t size) { +void CpuFeatures::FlushICache(void* start, size_t size) { // No need to flush the instruction cache on Intel. On Intel instruction // cache flushing is only necessary when multiple cores running the same // code simultaneously. V8 (and JavaScript) is single threaded and when code diff --git a/src/ia32/lithium-codegen-ia32.h b/src/ia32/lithium-codegen-ia32.h index 64a6b3c..2deafb8 100644 --- a/src/ia32/lithium-codegen-ia32.h +++ b/src/ia32/lithium-codegen-ia32.h @@ -7,7 +7,7 @@ #include "src/ia32/lithium-ia32.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/deoptimizer.h" #include "src/ia32/lithium-gap-resolver-ia32.h" #include "src/lithium-codegen.h" diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 07bc737..b3cb507 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -992,7 +992,7 @@ void MacroAssembler::EnterExitFrameEpilogue(int argc, bool save_doubles) { } // Get the required frame alignment for the OS. - const int kFrameAlignment = OS::ActivationFrameAlignment(); + const int kFrameAlignment = base::OS::ActivationFrameAlignment(); if (kFrameAlignment > 0) { ASSERT(IsPowerOf2(kFrameAlignment)); and_(esp, -kFrameAlignment); @@ -2762,7 +2762,7 @@ void MacroAssembler::Check(Condition cc, BailoutReason reason) { void MacroAssembler::CheckStackAlignment() { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); int frame_alignment_mask = frame_alignment - 1; if (frame_alignment > kPointerSize) { ASSERT(IsPowerOf2(frame_alignment)); @@ -2999,7 +2999,7 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string, void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); if (frame_alignment != 0) { // Make stack end at alignment and make room for num_arguments words // and the original value of esp. @@ -3031,7 +3031,7 @@ void MacroAssembler::CallCFunction(Register function, } call(function); - if (OS::ActivationFrameAlignment() != 0) { + if (base::OS::ActivationFrameAlignment() != 0) { mov(esp, Operand(esp, num_arguments * kPointerSize)); } else { add(esp, Immediate(num_arguments * kPointerSize)); @@ -3063,7 +3063,7 @@ CodePatcher::CodePatcher(byte* address, int size) CodePatcher::~CodePatcher() { // Indicate that code has changed. - CPU::FlushICache(address_, size_); + CpuFeatures::FlushICache(address_, size_); // Check that the code was patched as expected. ASSERT(masm_.pc_ == address_ + size_); diff --git a/src/ic.cc b/src/ic.cc index b4ef2b8..5a4135b 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -448,7 +448,7 @@ void IC::InvalidateMaps(Code* stub) { it.rinfo()->set_target_object(undefined, SKIP_WRITE_BARRIER); } } - CPU::FlushICache(stub->instruction_start(), stub->instruction_size()); + CpuFeatures::FlushICache(stub->instruction_start(), stub->instruction_size()); } diff --git a/src/incremental-marking.cc b/src/incremental-marking.cc index 8a158c3..f9575c3 100644 --- a/src/incremental-marking.cc +++ b/src/incremental-marking.cc @@ -499,7 +499,7 @@ static void PatchIncrementalMarkingRecordWriteStubs( void IncrementalMarking::EnsureMarkingDequeIsCommitted() { if (marking_deque_memory_ == NULL) { - marking_deque_memory_ = new VirtualMemory(4 * MB); + marking_deque_memory_ = new base::VirtualMemory(4 * MB); } if (!marking_deque_memory_committed_) { bool success = marking_deque_memory_->Commit( @@ -723,7 +723,7 @@ void IncrementalMarking::Hurry() { if (state() == MARKING) { double start = 0.0; if (FLAG_trace_incremental_marking || FLAG_print_cumulative_gc_stat) { - start = OS::TimeCurrentMillis(); + start = base::OS::TimeCurrentMillis(); if (FLAG_trace_incremental_marking) { PrintF("[IncrementalMarking] Hurry\n"); } @@ -733,7 +733,7 @@ void IncrementalMarking::Hurry() { ProcessMarkingDeque(); state_ = COMPLETE; if (FLAG_trace_incremental_marking || FLAG_print_cumulative_gc_stat) { - double end = OS::TimeCurrentMillis(); + double end = base::OS::TimeCurrentMillis(); double delta = end - start; heap_->AddMarkingTime(delta); if (FLAG_trace_incremental_marking) { @@ -876,7 +876,7 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, if (FLAG_trace_incremental_marking || FLAG_trace_gc || FLAG_print_cumulative_gc_stat) { - start = OS::TimeCurrentMillis(); + start = base::OS::TimeCurrentMillis(); } if (state_ == SWEEPING) { @@ -961,7 +961,7 @@ void IncrementalMarking::Step(intptr_t allocated_bytes, if (FLAG_trace_incremental_marking || FLAG_trace_gc || FLAG_print_cumulative_gc_stat) { - double end = OS::TimeCurrentMillis(); + double end = base::OS::TimeCurrentMillis(); double delta = (end - start); longest_step_ = Max(longest_step_, delta); steps_took_ += delta; diff --git a/src/incremental-marking.h b/src/incremental-marking.h index 31b9714..8f79e02 100644 --- a/src/incremental-marking.h +++ b/src/incremental-marking.h @@ -231,7 +231,7 @@ class IncrementalMarking { State state_; bool is_compacting_; - VirtualMemory* marking_deque_memory_; + base::VirtualMemory* marking_deque_memory_; bool marking_deque_memory_committed_; MarkingDeque marking_deque_; diff --git a/src/isolate-inl.h b/src/isolate-inl.h index 12a861f..b44c4d6 100644 --- a/src/isolate-inl.h +++ b/src/isolate-inl.h @@ -5,9 +5,9 @@ #ifndef V8_ISOLATE_INL_H_ #define V8_ISOLATE_INL_H_ +#include "src/base/utils/random-number-generator.h" #include "src/debug.h" #include "src/isolate.h" -#include "src/utils/random-number-generator.h" namespace v8 { namespace internal { @@ -30,12 +30,13 @@ bool Isolate::DebuggerHasBreakPoints() { } -RandomNumberGenerator* Isolate::random_number_generator() { +base::RandomNumberGenerator* Isolate::random_number_generator() { if (random_number_generator_ == NULL) { if (FLAG_random_seed != 0) { - random_number_generator_ = new RandomNumberGenerator(FLAG_random_seed); + random_number_generator_ = + new base::RandomNumberGenerator(FLAG_random_seed); } else { - random_number_generator_ = new RandomNumberGenerator(); + random_number_generator_ = new base::RandomNumberGenerator(); } } return random_number_generator_; diff --git a/src/isolate.cc b/src/isolate.cc index 9bffca2..10b1db1 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -7,6 +7,8 @@ #include "src/v8.h" #include "src/ast.h" +#include "src/base/platform/platform.h" +#include "src/base/utils/random-number-generator.h" #include "src/bootstrapper.h" #include "src/codegen.h" #include "src/compilation-cache.h" @@ -19,7 +21,6 @@ #include "src/lithium-allocator.h" #include "src/log.h" #include "src/messages.h" -#include "src/platform.h" #include "src/regexp-stack.h" #include "src/runtime-profiler.h" #include "src/sampler.h" @@ -29,7 +30,6 @@ #include "src/spaces.h" #include "src/stub-cache.h" #include "src/sweeper-thread.h" -#include "src/utils/random-number-generator.h" #include "src/version.h" #include "src/vm-state-inl.h" @@ -46,10 +46,10 @@ int ThreadId::AllocateThreadId() { int ThreadId::GetCurrentThreadId() { - int thread_id = Thread::GetThreadLocalInt(Isolate::thread_id_key_); + int thread_id = base::Thread::GetThreadLocalInt(Isolate::thread_id_key_); if (thread_id == 0) { thread_id = AllocateThreadId(); - Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); + base::Thread::SetThreadLocalInt(Isolate::thread_id_key_, thread_id); } return thread_id; } @@ -98,13 +98,13 @@ void ThreadLocalTop::Initialize() { } -Thread::LocalStorageKey Isolate::isolate_key_; -Thread::LocalStorageKey Isolate::thread_id_key_; -Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; +base::Thread::LocalStorageKey Isolate::isolate_key_; +base::Thread::LocalStorageKey Isolate::thread_id_key_; +base::Thread::LocalStorageKey Isolate::per_isolate_thread_data_key_; #ifdef DEBUG -Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; +base::Thread::LocalStorageKey PerThreadAssertScopeBase::thread_local_key; #endif // DEBUG -Mutex Isolate::process_wide_mutex_; +base::Mutex Isolate::process_wide_mutex_; // TODO(dcarney): Remove with default isolate. enum DefaultIsolateStatus { kDefaultIsolateUninitialized, @@ -121,7 +121,7 @@ Isolate::PerIsolateThreadData* ThreadId thread_id = ThreadId::Current(); PerIsolateThreadData* per_thread = NULL; { - LockGuard lock_guard(&process_wide_mutex_); + base::LockGuard lock_guard(&process_wide_mutex_); per_thread = thread_data_table_->Lookup(this, thread_id); if (per_thread == NULL) { per_thread = new PerIsolateThreadData(this, thread_id); @@ -143,7 +143,7 @@ Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( ThreadId thread_id) { PerIsolateThreadData* per_thread = NULL; { - LockGuard lock_guard(&process_wide_mutex_); + base::LockGuard lock_guard(&process_wide_mutex_); per_thread = thread_data_table_->Lookup(this, thread_id); } return per_thread; @@ -151,21 +151,22 @@ Isolate::PerIsolateThreadData* Isolate::FindPerThreadDataForThread( void Isolate::SetCrashIfDefaultIsolateInitialized() { - LockGuard lock_guard(&process_wide_mutex_); + base::LockGuard lock_guard(&process_wide_mutex_); CHECK(default_isolate_status_ != kDefaultIsolateInitialized); default_isolate_status_ = kDefaultIsolateCrashIfInitialized; } void Isolate::EnsureDefaultIsolate() { - LockGuard lock_guard(&process_wide_mutex_); + base::LockGuard lock_guard(&process_wide_mutex_); CHECK(default_isolate_status_ != kDefaultIsolateCrashIfInitialized); if (thread_data_table_ == NULL) { - isolate_key_ = Thread::CreateThreadLocalKey(); - thread_id_key_ = Thread::CreateThreadLocalKey(); - per_isolate_thread_data_key_ = Thread::CreateThreadLocalKey(); + isolate_key_ = base::Thread::CreateThreadLocalKey(); + thread_id_key_ = base::Thread::CreateThreadLocalKey(); + per_isolate_thread_data_key_ = base::Thread::CreateThreadLocalKey(); #ifdef DEBUG - PerThreadAssertScopeBase::thread_local_key = Thread::CreateThreadLocalKey(); + PerThreadAssertScopeBase::thread_local_key = + base::Thread::CreateThreadLocalKey(); #endif // DEBUG thread_data_table_ = new Isolate::ThreadDataTable(); } @@ -286,14 +287,14 @@ Handle Isolate::StackTraceString() { return stack_trace; } else if (stack_trace_nesting_level_ == 1) { stack_trace_nesting_level_++; - OS::PrintError( + base::OS::PrintError( "\n\nAttempt to print stack while printing stack (double fault)\n"); - OS::PrintError( + base::OS::PrintError( "If you are lucky you may find a partial stack dump on stdout.\n\n"); incomplete_message_->OutputToStdOut(); return factory()->empty_string(); } else { - OS::Abort(); + base::OS::Abort(); // Unreachable return factory()->empty_string(); } @@ -311,11 +312,10 @@ void Isolate::PushStackTraceAndDie(unsigned int magic, String::WriteToFlat(*trace, buffer, 0, length); buffer[length] = '\0'; // TODO(dcarney): convert buffer to utf8? - OS::PrintError("Stacktrace (%x-%x) %p %p: %s\n", - magic, magic2, - static_cast(object), static_cast(map), - reinterpret_cast(buffer)); - OS::Abort(); + base::OS::PrintError("Stacktrace (%x-%x) %p %p: %s\n", magic, magic2, + static_cast(object), static_cast(map), + reinterpret_cast(buffer)); + base::OS::Abort(); } @@ -571,9 +571,9 @@ void Isolate::PrintStack(FILE* out) { stack_trace_nesting_level_ = 0; } else if (stack_trace_nesting_level_ == 1) { stack_trace_nesting_level_++; - OS::PrintError( + base::OS::PrintError( "\n\nAttempt to print stack while printing stack (double fault)\n"); - OS::PrintError( + base::OS::PrintError( "If you are lucky you may find a partial stack dump on stdout.\n\n"); incomplete_message_->OutputToFile(out); } @@ -1108,7 +1108,7 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) { "%s\n\nFROM\n", MessageHandler::GetLocalizedMessage(this, message_obj).get()); PrintCurrentStackTrace(stderr); - OS::Abort(); + base::OS::Abort(); } } else if (location != NULL && !location->script().is_null()) { // We are bootstrapping and caught an error where the location is set @@ -1119,18 +1119,18 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) { int line_number = location->script()->GetLineNumber(location->start_pos()) + 1; if (exception->IsString() && location->script()->name()->IsString()) { - OS::PrintError( + base::OS::PrintError( "Extension or internal compilation error: %s in %s at line %d.\n", String::cast(exception)->ToCString().get(), String::cast(location->script()->name())->ToCString().get(), line_number); } else if (location->script()->name()->IsString()) { - OS::PrintError( + base::OS::PrintError( "Extension or internal compilation error in %s at line %d.\n", String::cast(location->script()->name())->ToCString().get(), line_number); } else { - OS::PrintError("Extension or internal compilation error.\n"); + base::OS::PrintError("Extension or internal compilation error.\n"); } #ifdef OBJECT_PRINT // Since comments and empty lines have been stripped from the source of @@ -1531,7 +1531,7 @@ void Isolate::TearDown() { Deinit(); - { LockGuard lock_guard(&process_wide_mutex_); + { base::LockGuard lock_guard(&process_wide_mutex_); thread_data_table_->RemoveAllThreads(this); } @@ -1632,8 +1632,8 @@ void Isolate::PushToPartialSnapshotCache(Object* obj) { void Isolate::SetIsolateThreadLocals(Isolate* isolate, PerIsolateThreadData* data) { - Thread::SetThreadLocal(isolate_key_, isolate); - Thread::SetThreadLocal(per_isolate_thread_data_key_, data); + base::Thread::SetThreadLocal(isolate_key_, isolate); + base::Thread::SetThreadLocal(per_isolate_thread_data_key_, data); } @@ -1901,7 +1901,8 @@ bool Isolate::Init(Deserializer* des) { // once ResourceConstraints becomes an argument to the Isolate constructor. if (max_available_threads_ < 1) { // Choose the default between 1 and 4. - max_available_threads_ = Max(Min(OS::NumberOfProcessorsOnline(), 4), 1); + max_available_threads_ = + Max(Min(base::OS::NumberOfProcessorsOnline(), 4), 1); } if (!FLAG_job_based_sweeping) { @@ -1976,7 +1977,7 @@ bool Isolate::Init(Deserializer* des) { Internals::kAmountOfExternalAllocatedMemoryAtLastGlobalGCOffset); state_ = INITIALIZED; - time_millis_at_init_ = OS::TimeCurrentMillis(); + time_millis_at_init_ = base::OS::TimeCurrentMillis(); if (!create_heap_objects) { // Now that the heap is consistent, it's OK to generate the code for the diff --git a/src/isolate.h b/src/isolate.h index ed2ed33..157839f 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -25,6 +25,11 @@ #include "src/zone.h" namespace v8 { + +namespace base { +class RandomNumberGenerator; +} + namespace internal { class Bootstrapper; @@ -55,7 +60,6 @@ class InnerPointerToCodeCache; class MaterializedObjectStore; class NoAllocationStringAllocator; class CodeAgingHelper; -class RandomNumberGenerator; class RegExpStack; class SaveContext; class StringTracker; @@ -445,19 +449,20 @@ class Isolate { // not currently set). static PerIsolateThreadData* CurrentPerIsolateThreadData() { return reinterpret_cast( - Thread::GetThreadLocal(per_isolate_thread_data_key_)); + base::Thread::GetThreadLocal(per_isolate_thread_data_key_)); } // Returns the isolate inside which the current thread is running. INLINE(static Isolate* Current()) { Isolate* isolate = reinterpret_cast( - Thread::GetExistingThreadLocal(isolate_key_)); + base::Thread::GetExistingThreadLocal(isolate_key_)); ASSERT(isolate != NULL); return isolate; } INLINE(static Isolate* UncheckedCurrent()) { - return reinterpret_cast(Thread::GetThreadLocal(isolate_key_)); + return reinterpret_cast( + base::Thread::GetThreadLocal(isolate_key_)); } // Usually called by Init(), but can be called early e.g. to allow @@ -499,19 +504,19 @@ class Isolate { // Returns the key used to store the pointer to the current isolate. // Used internally for V8 threads that do not execute JavaScript but still // are part of the domain of an isolate (like the context switcher). - static Thread::LocalStorageKey isolate_key() { + static base::Thread::LocalStorageKey isolate_key() { return isolate_key_; } // Returns the key used to store process-wide thread IDs. - static Thread::LocalStorageKey thread_id_key() { + static base::Thread::LocalStorageKey thread_id_key() { return thread_id_key_; } - static Thread::LocalStorageKey per_isolate_thread_data_key(); + static base::Thread::LocalStorageKey per_isolate_thread_data_key(); // Mutex for serializing access to break control structures. - RecursiveMutex* break_access() { return &break_access_; } + base::RecursiveMutex* break_access() { return &break_access_; } Address get_address_from_id(AddressId id); @@ -979,7 +984,7 @@ class Isolate { bool initialized_from_snapshot() { return initialized_from_snapshot_; } double time_millis_since_init() { - return OS::TimeCurrentMillis() - time_millis_at_init_; + return base::OS::TimeCurrentMillis() - time_millis_at_init_; } DateCache* date_cache() { @@ -1058,7 +1063,7 @@ class Isolate { void* stress_deopt_count_address() { return &stress_deopt_count_; } - inline RandomNumberGenerator* random_number_generator(); + inline base::RandomNumberGenerator* random_number_generator(); // Given an address occupied by a live code object, return that object. Object* FindCodeObject(Address a); @@ -1144,11 +1149,11 @@ class Isolate { }; // This mutex protects highest_thread_id_ and thread_data_table_. - static Mutex process_wide_mutex_; + static base::Mutex process_wide_mutex_; - static Thread::LocalStorageKey per_isolate_thread_data_key_; - static Thread::LocalStorageKey isolate_key_; - static Thread::LocalStorageKey thread_id_key_; + static base::Thread::LocalStorageKey per_isolate_thread_data_key_; + static base::Thread::LocalStorageKey isolate_key_; + static base::Thread::LocalStorageKey thread_id_key_; static ThreadDataTable* thread_data_table_; // A global counter for all generated Isolates, might overflow. @@ -1202,7 +1207,7 @@ class Isolate { CompilationCache* compilation_cache_; Counters* counters_; CodeRange* code_range_; - RecursiveMutex break_access_; + base::RecursiveMutex break_access_; base::Atomic32 debugger_initialized_; Logger* logger_; StackGuard stack_guard_; @@ -1244,7 +1249,7 @@ class Isolate { unibrow::Mapping interp_canonicalize_mapping_; CodeStubInterfaceDescriptor* code_stub_interface_descriptors_; CallInterfaceDescriptor* call_descriptors_; - RandomNumberGenerator* random_number_generator_; + base::RandomNumberGenerator* random_number_generator_; // Whether the isolate has been created for snapshotting. bool serializer_enabled_; @@ -1452,7 +1457,7 @@ class CodeTracer V8_FINAL : public Malloced { if (FLAG_redirect_code_traces_to == NULL) { SNPrintF(filename_, "code-%d-%d.asm", - OS::GetCurrentProcessId(), + base::OS::GetCurrentProcessId(), isolate_id); } else { StrNCpy(filename_, FLAG_redirect_code_traces_to, filename_.length()); @@ -1478,7 +1483,7 @@ class CodeTracer V8_FINAL : public Malloced { } if (file_ == NULL) { - file_ = OS::FOpen(filename_.start(), "a"); + file_ = base::OS::FOpen(filename_.start(), "a"); } scope_depth_++; diff --git a/src/json-parser.h b/src/json-parser.h index 09320ab..e4f8f8c 100644 --- a/src/json-parser.h +++ b/src/json-parser.h @@ -528,7 +528,7 @@ Handle JsonParser::ParseJsonNumber() { number = StringToDouble(isolate()->unicode_cache(), chars, NO_FLAGS, // Hex, octal or trailing junk. - OS::nan_value()); + base::OS::nan_value()); } else { Vector buffer = Vector::New(length); String::WriteToFlat(*source_, buffer.start(), beg_pos, position_); diff --git a/src/jsregexp.cc b/src/jsregexp.cc index 5962bde..18004e3 100644 --- a/src/jsregexp.cc +++ b/src/jsregexp.cc @@ -5,6 +5,7 @@ #include "src/v8.h" #include "src/ast.h" +#include "src/base/platform/platform.h" #include "src/compilation-cache.h" #include "src/compiler.h" #include "src/execution.h" @@ -12,7 +13,6 @@ #include "src/jsregexp-inl.h" #include "src/jsregexp.h" #include "src/parser.h" -#include "src/platform.h" #include "src/regexp-macro-assembler.h" #include "src/regexp-macro-assembler-irregexp.h" #include "src/regexp-macro-assembler-tracer.h" @@ -4655,7 +4655,7 @@ void DispatchTable::Dump() { StringStream stream(&alloc); DispatchTableDumper dumper(&stream); tree()->ForEach(&dumper); - OS::PrintError("%s", stream.ToCString().get()); + base::OS::PrintError("%s", stream.ToCString().get()); } diff --git a/src/libplatform/DEPS b/src/libplatform/DEPS index bace5d3..bba4fa0 100644 --- a/src/libplatform/DEPS +++ b/src/libplatform/DEPS @@ -1,6 +1,5 @@ include_rules = [ - # TODO(jochen): Enable this. - #"-src", + "-src", "+src/base", "+src/libplatform", ] diff --git a/src/libplatform/default-platform.cc b/src/libplatform/default-platform.cc index 994a517..3cba2f6 100644 --- a/src/libplatform/default-platform.cc +++ b/src/libplatform/default-platform.cc @@ -7,10 +7,9 @@ #include #include -// TODO(jochen): We should have our own version of checks.h. -#include "src/checks.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" #include "src/libplatform/worker-thread.h" -#include "src/platform.h" namespace v8 { namespace internal { @@ -24,7 +23,7 @@ DefaultPlatform::DefaultPlatform() DefaultPlatform::~DefaultPlatform() { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); queue_.Terminate(); if (initialized_) { for (std::vector::iterator i = thread_pool_.begin(); @@ -36,17 +35,17 @@ DefaultPlatform::~DefaultPlatform() { void DefaultPlatform::SetThreadPoolSize(int thread_pool_size) { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); ASSERT(thread_pool_size >= 0); if (thread_pool_size < 1) - thread_pool_size = OS::NumberOfProcessorsOnline(); + thread_pool_size = base::OS::NumberOfProcessorsOnline(); thread_pool_size_ = std::max(std::min(thread_pool_size, kMaxThreadPoolSize), 1); } void DefaultPlatform::EnsureInitialized() { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); if (initialized_) return; initialized_ = true; diff --git a/src/libplatform/default-platform.h b/src/libplatform/default-platform.h index e38ca60..14e002b 100644 --- a/src/libplatform/default-platform.h +++ b/src/libplatform/default-platform.h @@ -9,8 +9,8 @@ #include "include/v8-platform.h" #include "src/base/macros.h" +#include "src/base/platform/mutex.h" #include "src/libplatform/task-queue.h" -#include "src/platform/mutex.h" namespace v8 { namespace internal { @@ -37,7 +37,7 @@ class DefaultPlatform : public Platform { private: static const int kMaxThreadPoolSize; - Mutex lock_; + base::Mutex lock_; bool initialized_; int thread_pool_size_; std::vector thread_pool_; diff --git a/src/libplatform/task-queue.cc b/src/libplatform/task-queue.cc index e618cb7..a5d08f1 100644 --- a/src/libplatform/task-queue.cc +++ b/src/libplatform/task-queue.cc @@ -4,8 +4,7 @@ #include "src/libplatform/task-queue.h" -// TODO(jochen): We should have our own version of checks.h. -#include "src/checks.h" +#include "src/base/logging.h" namespace v8 { namespace internal { @@ -14,14 +13,14 @@ TaskQueue::TaskQueue() : process_queue_semaphore_(0), terminated_(false) {} TaskQueue::~TaskQueue() { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); ASSERT(terminated_); ASSERT(task_queue_.empty()); } void TaskQueue::Append(Task* task) { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); ASSERT(!terminated_); task_queue_.push(task); process_queue_semaphore_.Signal(); @@ -31,7 +30,7 @@ void TaskQueue::Append(Task* task) { Task* TaskQueue::GetNext() { for (;;) { { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); if (!task_queue_.empty()) { Task* result = task_queue_.front(); task_queue_.pop(); @@ -48,7 +47,7 @@ Task* TaskQueue::GetNext() { void TaskQueue::Terminate() { - LockGuard guard(&lock_); + base::LockGuard guard(&lock_); ASSERT(!terminated_); terminated_ = true; process_queue_semaphore_.Signal(); diff --git a/src/libplatform/task-queue.h b/src/libplatform/task-queue.h index 1403664..f438cb5 100644 --- a/src/libplatform/task-queue.h +++ b/src/libplatform/task-queue.h @@ -8,8 +8,8 @@ #include #include "src/base/macros.h" -#include "src/platform/mutex.h" -#include "src/platform/semaphore.h" +#include "src/base/platform/mutex.h" +#include "src/base/platform/semaphore.h" namespace v8 { @@ -33,8 +33,8 @@ class TaskQueue { void Terminate(); private: - Mutex lock_; - Semaphore process_queue_semaphore_; + base::Mutex lock_; + base::Semaphore process_queue_semaphore_; std::queue task_queue_; bool terminated_; diff --git a/src/libplatform/worker-thread.h b/src/libplatform/worker-thread.h index 20b9add..5942b93 100644 --- a/src/libplatform/worker-thread.h +++ b/src/libplatform/worker-thread.h @@ -8,7 +8,7 @@ #include #include "src/base/macros.h" -#include "src/platform.h" +#include "src/base/platform/platform.h" namespace v8 { @@ -16,7 +16,7 @@ namespace internal { class TaskQueue; -class WorkerThread : public Thread { +class WorkerThread : public base::Thread { public: explicit WorkerThread(TaskQueue* queue); virtual ~WorkerThread(); diff --git a/src/list-inl.h b/src/list-inl.h index fd1050e..ee68b36 100644 --- a/src/list-inl.h +++ b/src/list-inl.h @@ -6,7 +6,8 @@ #define V8_LIST_INL_H_ #include "src/list.h" -#include "src/platform.h" + +#include "src/base/platform/platform.h" namespace v8 { namespace internal { diff --git a/src/list.h b/src/list.h index 2244d67..8817179 100644 --- a/src/list.h +++ b/src/list.h @@ -5,6 +5,7 @@ #ifndef V8_LIST_H_ #define V8_LIST_H_ +#include "src/checks.h" #include "src/utils.h" namespace v8 { diff --git a/src/lithium-allocator.cc b/src/lithium-allocator.cc index ad03575..3a9c2a3 100644 --- a/src/lithium-allocator.cc +++ b/src/lithium-allocator.cc @@ -1618,7 +1618,7 @@ void LAllocator::TraceAlloc(const char* msg, ...) { if (FLAG_trace_alloc) { va_list arguments; va_start(arguments, msg); - OS::VPrint(msg, arguments); + base::OS::VPrint(msg, arguments); va_end(arguments); } } @@ -2192,7 +2192,7 @@ LAllocatorPhase::~LAllocatorPhase() { if (FLAG_hydrogen_stats) { unsigned size = allocator_->zone()->allocation_size() - allocator_zone_start_allocation_size_; - isolate()->GetHStatistics()->SaveTiming(name(), TimeDelta(), size); + isolate()->GetHStatistics()->SaveTiming(name(), base::TimeDelta(), size); } if (ShouldProduceTraceOutput()) { diff --git a/src/log-utils.cc b/src/log-utils.cc index 4598b81..8f01225 100644 --- a/src/log-utils.cc +++ b/src/log-utils.cc @@ -61,13 +61,13 @@ void Log::OpenStdout() { void Log::OpenTemporaryFile() { ASSERT(!IsEnabled()); - output_handle_ = i::OS::OpenTemporaryFile(); + output_handle_ = base::OS::OpenTemporaryFile(); } void Log::OpenFile(const char* name) { ASSERT(!IsEnabled()); - output_handle_ = OS::FOpen(name, OS::LogFileOpenMode); + output_handle_ = base::OS::FOpen(name, base::OS::LogFileOpenMode); } diff --git a/src/log-utils.h b/src/log-utils.h index c5e0a0c..451ffaa 100644 --- a/src/log-utils.h +++ b/src/log-utils.h @@ -85,7 +85,7 @@ class Log { private: Log* log_; - LockGuard lock_guard_; + base::LockGuard lock_guard_; int pos_; }; @@ -120,7 +120,7 @@ class Log { // mutex_ is a Mutex used for enforcing exclusive // access to the formatting buffer and the log file or log memory buffer. - Mutex mutex_; + base::Mutex mutex_; // Buffer used for formatting log messages. This is a singleton buffer and // mutex_ should be acquired before using it. diff --git a/src/log.cc b/src/log.cc index 9603fc1..6d88a53 100644 --- a/src/log.cc +++ b/src/log.cc @@ -6,6 +6,7 @@ #include "src/v8.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/code-stubs.h" #include "src/cpu-profiler.h" @@ -14,7 +15,6 @@ #include "src/log.h" #include "src/log-utils.h" #include "src/macro-assembler.h" -#include "src/platform.h" #include "src/runtime-profiler.h" #include "src/serialize.h" #include "src/string-stream.h" @@ -262,9 +262,10 @@ PerfBasicLogger::PerfBasicLogger() int size = SNPrintF( perf_dump_name, kFilenameFormatString, - OS::GetCurrentProcessId()); + base::OS::GetCurrentProcessId()); CHECK_NE(size, -1); - perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode); + perf_output_handle_ = + base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); CHECK_NE(perf_output_handle_, NULL); setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); } @@ -282,10 +283,9 @@ void PerfBasicLogger::LogRecordedBuffer(Code* code, int length) { ASSERT(code->instruction_start() == code->address() + Code::kHeaderSize); - OS::FPrint(perf_output_handle_, "%llx %x %.*s\n", - reinterpret_cast(code->instruction_start()), - code->instruction_size(), - length, name); + base::OS::FPrint(perf_output_handle_, "%llx %x %.*s\n", + reinterpret_cast(code->instruction_start()), + code->instruction_size(), length, name); } @@ -386,9 +386,10 @@ PerfJitLogger::PerfJitLogger() int size = SNPrintF( perf_dump_name, kFilenameFormatString, - OS::GetCurrentProcessId()); + base::OS::GetCurrentProcessId()); CHECK_NE(size, -1); - perf_output_handle_ = OS::FOpen(perf_dump_name.start(), OS::LogFileOpenMode); + perf_output_handle_ = + base::OS::FOpen(perf_dump_name.start(), base::OS::LogFileOpenMode); CHECK_NE(perf_output_handle_, NULL); setvbuf(perf_output_handle_, NULL, _IOFBF, kLogBufferSize); @@ -419,7 +420,7 @@ void PerfJitLogger::LogRecordedBuffer(Code* code, code_load.id = JIT_CODE_LOAD; code_load.total_size = sizeof(code_load) + length + 1 + code_size; code_load.timestamp = - static_cast(OS::TimeCurrentMillis() * 1000.0); + static_cast(base::OS::TimeCurrentMillis() * 1000.0); code_load.vma = 0x0; // Our addresses are absolute. code_load.code_addr = reinterpret_cast(code->instruction_start()); code_load.code_size = code_size; @@ -447,8 +448,9 @@ void PerfJitLogger::LogWriteHeader() { header.total_size = sizeof(jitheader); header.pad1 = 0xdeadbeef; header.elf_mach = GetElfMach(); - header.pid = OS::GetCurrentProcessId(); - header.timestamp = static_cast(OS::TimeCurrentMillis() * 1000.0); + header.pid = base::OS::GetCurrentProcessId(); + header.timestamp = + static_cast(base::OS::TimeCurrentMillis() * 1000.0); LogWriteBytes(reinterpret_cast(&header), sizeof(header)); } @@ -538,7 +540,8 @@ LowLevelLogger::LowLevelLogger(const char* name) ScopedVector ll_name(static_cast(len + sizeof(kLogExt))); MemCopy(ll_name.start(), name, len); MemCopy(ll_name.start() + len, kLogExt, sizeof(kLogExt)); - ll_output_handle_ = OS::FOpen(ll_name.start(), OS::LogFileOpenMode); + ll_output_handle_ = + base::OS::FOpen(ll_name.start(), base::OS::LogFileOpenMode); setvbuf(ll_output_handle_, NULL, _IOFBF, kLogBufferSize); LogCodeInfo(); @@ -755,7 +758,7 @@ void JitLogger::EndCodePosInfoEvent(Code* code, void* jit_handler_data) { // An independent thread removes data and writes it to the log. // This design minimizes the time spent in the sampler. // -class Profiler: public Thread { +class Profiler: public base::Thread { public: explicit Profiler(Isolate* isolate); void Engage(); @@ -804,7 +807,7 @@ class Profiler: public Thread { int tail_; // Index to the buffer tail. bool overflow_; // Tell whether a buffer overflow has occurred. // Sempahore used for buffer synchronization. - Semaphore buffer_semaphore_; + base::Semaphore buffer_semaphore_; // Tells whether profiler is engaged, that is, processing thread is stated. bool engaged_; @@ -855,7 +858,7 @@ class Ticker: public Sampler { // Profiler implementation. // Profiler::Profiler(Isolate* isolate) - : Thread("v8:Profiler"), + : base::Thread("v8:Profiler"), isolate_(isolate), head_(0), tail_(0), @@ -871,8 +874,8 @@ void Profiler::Engage() { if (engaged_) return; engaged_ = true; - std::vector addresses = - OS::GetSharedLibraryAddresses(); + std::vector addresses = + base::OS::GetSharedLibraryAddresses(); for (size_t i = 0; i < addresses.size(); ++i) { LOG(isolate_, SharedLibraryEvent( addresses[i].library_path, addresses[i].start, addresses[i].end)); @@ -1486,7 +1489,7 @@ void Logger::CodeMovingGCEvent() { if (!is_logging_code_events()) return; if (!log_->IsEnabled() || !FLAG_ll_prof) return; CALL_LISTENERS(CodeMovingGCEvent()); - OS::SignalCodeMovingGC(); + base::OS::SignalCodeMovingGC(); } @@ -1615,10 +1618,10 @@ void Logger::ResourceEvent(const char* name, const char* tag) { msg.Append("%s,%s,", name, tag); uint32_t sec, usec; - if (OS::GetUserTime(&sec, &usec) != -1) { + if (base::OS::GetUserTime(&sec, &usec) != -1) { msg.Append("%d,%d,", sec, usec); } - msg.Append("%.0f", OS::TimeCurrentMillis()); + msg.Append("%.0f", base::OS::TimeCurrentMillis()); msg.Append('\n'); msg.WriteToLogFile(); @@ -1652,7 +1655,7 @@ void Logger::HeapSampleBeginEvent(const char* space, const char* kind) { // Using non-relative system time in order to be able to synchronize with // external memory profiling events (e.g. DOM memory size). msg.Append("heap-sample-begin,\"%s\",\"%s\",%.0f\n", - space, kind, OS::TimeCurrentMillis()); + space, kind, base::OS::TimeCurrentMillis()); msg.WriteToLogFile(); } @@ -1691,7 +1694,7 @@ void Logger::DebugEvent(const char* event_type, Vector parameter) { Log::MessageBuilder msg(log_); msg.Append("debug-queue-event,%s,%15.3f,%s\n", event_type, - OS::TimeCurrentMillis(), + base::OS::TimeCurrentMillis(), parameter_string); DeleteArray(parameter_string); msg.WriteToLogFile(); @@ -1989,11 +1992,11 @@ static SmartArrayPointer PrepareLogFileName( p--; break; case 'p': - stream.Add("%d", OS::GetCurrentProcessId()); + stream.Add("%d", base::OS::GetCurrentProcessId()); break; case 't': { // %t expands to the current time in milliseconds. - double time = OS::TimeCurrentMillis(); + double time = base::OS::TimeCurrentMillis(); stream.Add("%.0f", FmtElm(time)); break; } diff --git a/src/log.h b/src/log.h index e98874b..1b32fde 100644 --- a/src/log.h +++ b/src/log.h @@ -8,11 +8,16 @@ #include #include "src/allocation.h" +#include "src/base/platform/elapsed-timer.h" +#include "src/base/platform/platform.h" #include "src/objects.h" -#include "src/platform.h" -#include "src/platform/elapsed-timer.h" namespace v8 { + +namespace base { +class Semaphore; +} + namespace internal { // Logger is used for collecting logging information from V8 during @@ -57,7 +62,6 @@ class Isolate; class Log; class PositionsRecorder; class Profiler; -class Semaphore; class Ticker; struct TickSample; @@ -436,7 +440,7 @@ class Logger { // 'true' between SetUp() and TearDown(). bool is_initialized_; - ElapsedTimer timer_; + base::ElapsedTimer timer_; friend class CpuProfiler; }; diff --git a/src/mark-compact.cc b/src/mark-compact.cc index 2e05171..8846f19 100644 --- a/src/mark-compact.cc +++ b/src/mark-compact.cc @@ -613,7 +613,8 @@ bool MarkCompactCollector::IsSweepingCompleted() { } } if (FLAG_job_based_sweeping) { - if (!pending_sweeper_jobs_semaphore_.WaitFor(TimeDelta::FromSeconds(0))) { + if (!pending_sweeper_jobs_semaphore_.WaitFor( + base::TimeDelta::FromSeconds(0))) { return false; } pending_sweeper_jobs_semaphore_.Signal(); @@ -3239,7 +3240,7 @@ static void SweepPrecisely(PagedSpace* space, double start_time = 0.0; if (FLAG_print_cumulative_gc_stat) { - start_time = OS::TimeCurrentMillis(); + start_time = base::OS::TimeCurrentMillis(); } p->MarkSweptPrecisely(); @@ -3308,7 +3309,7 @@ static void SweepPrecisely(PagedSpace* space, } p->ResetLiveBytes(); if (FLAG_print_cumulative_gc_stat) { - space->heap()->AddSweepingTime(OS::TimeCurrentMillis() - start_time); + space->heap()->AddSweepingTime(base::OS::TimeCurrentMillis() - start_time); } } diff --git a/src/mark-compact.h b/src/mark-compact.h index 5cd6749..54f28dc 100644 --- a/src/mark-compact.h +++ b/src/mark-compact.h @@ -735,7 +735,7 @@ class MarkCompactCollector { // True if concurrent or parallel sweeping is currently in progress. bool sweeping_pending_; - Semaphore pending_sweeper_jobs_semaphore_; + base::Semaphore pending_sweeper_jobs_semaphore_; bool sequential_sweeping_; diff --git a/src/mips/assembler-mips-inl.h b/src/mips/assembler-mips-inl.h index eec19a6..086e55a 100644 --- a/src/mips/assembler-mips-inl.h +++ b/src/mips/assembler-mips-inl.h @@ -39,7 +39,7 @@ #include "src/mips/assembler-mips.h" -#include "src/cpu.h" +#include "src/assembler.h" #include "src/debug.h" @@ -125,7 +125,7 @@ void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { // Absolute code pointer inside code object moves with the code object. byte* p = reinterpret_cast(pc_); int count = Assembler::RelocateInternalReference(p, delta); - CPU::FlushICache(p, count * sizeof(uint32_t)); + CpuFeatures::FlushICache(p, count * sizeof(uint32_t)); } } diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc index e4bebfe..dcd3e8a 100644 --- a/src/mips/assembler-mips.cc +++ b/src/mips/assembler-mips.cc @@ -99,7 +99,7 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { supported_ |= 1u << FPU; #else // Probe for additional features at runtime. - CPU cpu; + base::CPU cpu; if (cpu.has_fpu()) supported_ |= 1u << FPU; #endif } @@ -198,7 +198,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count * Assembler::kInstrSize); + CpuFeatures::FlushICache(pc_, instruction_count * Assembler::kInstrSize); } @@ -2156,7 +2156,7 @@ Address Assembler::target_address_at(Address pc) { // snapshot generated on ia32, the resulting MIPS sNaN must be quieted. // OS::nan_value() returns a qNaN. void Assembler::QuietNaN(HeapObject* object) { - HeapNumber::cast(object)->set_value(OS::nan_value()); + HeapNumber::cast(object)->set_value(base::OS::nan_value()); } @@ -2264,7 +2264,7 @@ void Assembler::set_target_address_at(Address pc, } if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t)); + CpuFeatures::FlushICache(pc, (patched_jump ? 3 : 2) * sizeof(int32_t)); } } @@ -2298,7 +2298,7 @@ void Assembler::JumpLabelToJumpRegister(Address pc) { } if (patched) { - CPU::FlushICache(pc+2, sizeof(Address)); + CpuFeatures::FlushICache(pc+2, sizeof(Address)); } } diff --git a/src/mips/code-stubs-mips.h b/src/mips/code-stubs-mips.h index 3e0eaa1..f960bf3 100644 --- a/src/mips/code-stubs-mips.h +++ b/src/mips/code-stubs-mips.h @@ -271,7 +271,8 @@ class RecordWriteStub: public PlatformCodeStub { break; } ASSERT(GetMode(stub) == mode); - CPU::FlushICache(stub->instruction_start(), 4 * Assembler::kInstrSize); + CpuFeatures::FlushICache(stub->instruction_start(), + 4 * Assembler::kInstrSize); } private: diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc index 5d613d0..6754c68 100644 --- a/src/mips/codegen-mips.cc +++ b/src/mips/codegen-mips.cc @@ -29,7 +29,8 @@ double fast_exp_simulator(double x) { UnaryMathFunction CreateExpFunction() { if (!FLAG_fast_math) return &std::exp; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::exp; ExternalReference::InitializeMathExpData(); @@ -58,8 +59,8 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); #if !defined(USE_SIMULATOR) return FUNCTION_CAST(buffer); @@ -76,7 +77,8 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { return stub; #else size_t actual_size; - byte* buffer = static_cast(OS::Allocate(3 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(3 * KB, &actual_size, true)); if (buffer == NULL) return stub; // This code assumes that cache lines are 32 bytes and if the cache line is @@ -594,8 +596,8 @@ MemCopyUint8Function CreateMemCopyUint8Function(MemCopyUint8Function stub) { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif } @@ -606,7 +608,8 @@ UnaryMathFunction CreateSqrtFunction() { return &std::sqrt; #else size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::sqrt; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); @@ -620,8 +623,8 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); #endif } @@ -1175,7 +1178,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CPU::FlushICache(sequence, young_length); + CpuFeatures::FlushICache(sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length / Assembler::kInstrSize); diff --git a/src/mips/cpu-mips.cc b/src/mips/cpu-mips.cc index ce47126..f2d5065 100644 --- a/src/mips/cpu-mips.cc +++ b/src/mips/cpu-mips.cc @@ -15,7 +15,7 @@ #if V8_TARGET_ARCH_MIPS -#include "src/cpu.h" +#include "src/assembler.h" #include "src/macro-assembler.h" #include "src/simulator.h" // For cache flushing. @@ -24,7 +24,7 @@ namespace v8 { namespace internal { -void CPU::FlushICache(void* start, size_t size) { +void CpuFeatures::FlushICache(void* start, size_t size) { // Nothing to do, flushing no instructions. if (size == 0) { return; diff --git a/src/mips/disasm-mips.cc b/src/mips/disasm-mips.cc index 3cf071e..d64adbf 100644 --- a/src/mips/disasm-mips.cc +++ b/src/mips/disasm-mips.cc @@ -32,10 +32,10 @@ #if V8_TARGET_ARCH_MIPS +#include "src/base/platform/platform.h" #include "src/disasm.h" #include "src/macro-assembler.h" #include "src/mips/constants-mips.h" -#include "src/platform.h" namespace v8 { namespace internal { diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index 52e80d2..ce5cd90 100644 --- a/src/mips/macro-assembler-mips.cc +++ b/src/mips/macro-assembler-mips.cc @@ -4711,7 +4711,7 @@ int MacroAssembler::ActivationFrameAlignment() { // environment. // Note: This will break if we ever start generating snapshots on one Mips // platform for another Mips platform with a different alignment. - return OS::ActivationFrameAlignment(); + return base::OS::ActivationFrameAlignment(); #else // V8_HOST_ARCH_MIPS // If we are using the simulator then we should always align to the expected // alignment. As the simulator is used to generate snapshots we do not know @@ -5184,7 +5184,7 @@ void MacroAssembler::CallCFunctionHelper(Register function, #if V8_HOST_ARCH_MIPS if (emit_debug_code()) { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); int frame_alignment_mask = frame_alignment - 1; if (frame_alignment > kPointerSize) { ASSERT(IsPowerOf2(frame_alignment)); @@ -5213,7 +5213,7 @@ void MacroAssembler::CallCFunctionHelper(Register function, int stack_passed_arguments = CalculateStackPassedWords( num_reg_arguments, num_double_arguments); - if (OS::ActivationFrameAlignment() > kPointerSize) { + if (base::OS::ActivationFrameAlignment() > kPointerSize) { lw(sp, MemOperand(sp, stack_passed_arguments * kPointerSize)); } else { Addu(sp, sp, Operand(stack_passed_arguments * sizeof(kPointerSize))); @@ -5697,7 +5697,7 @@ CodePatcher::CodePatcher(byte* address, CodePatcher::~CodePatcher() { // Indicate that code has changed. if (flush_cache_ == FLUSH) { - CPU::FlushICache(address_, size_); + CpuFeatures::FlushICache(address_, size_); } // Check that the code was patched as expected. diff --git a/src/mips/macro-assembler-mips.h b/src/mips/macro-assembler-mips.h index 2fb04d2..c07b64b 100644 --- a/src/mips/macro-assembler-mips.h +++ b/src/mips/macro-assembler-mips.h @@ -713,7 +713,8 @@ class MacroAssembler: public Assembler { // into register dst. void LoadFromSafepointRegisterSlot(Register dst, Register src); - // Flush the I-cache from asm code. You should use CPU::FlushICache from C. + // Flush the I-cache from asm code. You should use CpuFeatures::FlushICache + // from C. // Does not handle errors. void FlushICache(Register address, unsigned instructions); diff --git a/src/mips/regexp-macro-assembler-mips.cc b/src/mips/regexp-macro-assembler-mips.cc index 3d47e51..e1a2729 100644 --- a/src/mips/regexp-macro-assembler-mips.cc +++ b/src/mips/regexp-macro-assembler-mips.cc @@ -1041,7 +1041,7 @@ bool RegExpMacroAssemblerMIPS::CanReadUnaligned() { // Private methods: void RegExpMacroAssemblerMIPS::CallCheckStackGuardState(Register scratch) { - int stack_alignment = OS::ActivationFrameAlignment(); + int stack_alignment = base::OS::ActivationFrameAlignment(); // Align the stack pointer and save the original sp value on the stack. __ mov(scratch, sp); diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc index 37bf79f..f329703 100644 --- a/src/mips/simulator-mips.cc +++ b/src/mips/simulator-mips.cc @@ -12,7 +12,6 @@ #if V8_TARGET_ARCH_MIPS #include "src/assembler.h" -#include "src/cpu.h" #include "src/disasm.h" #include "src/globals.h" // Need the BitCast. #include "src/mips/constants-mips.h" @@ -567,7 +566,7 @@ void MipsDebugger::Debug() { } } else if (strcmp(cmd, "gdb") == 0) { PrintF("relinquishing control to gdb\n"); - v8::internal::OS::DebugBreak(); + v8::base::OS::DebugBreak(); PrintF("regaining control from gdb\n"); } else if (strcmp(cmd, "break") == 0) { if (argc == 2) { @@ -1244,7 +1243,7 @@ double Simulator::ReadD(int32_t addr, Instruction* instr) { PrintF("Unaligned (double) read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); return 0; } @@ -1258,7 +1257,7 @@ void Simulator::WriteD(int32_t addr, double value, Instruction* instr) { PrintF("Unaligned (double) write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); } @@ -1270,7 +1269,7 @@ uint16_t Simulator::ReadHU(int32_t addr, Instruction* instr) { PrintF("Unaligned unsigned halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); return 0; } @@ -1283,7 +1282,7 @@ int16_t Simulator::ReadH(int32_t addr, Instruction* instr) { PrintF("Unaligned signed halfword read at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); return 0; } @@ -1297,7 +1296,7 @@ void Simulator::WriteH(int32_t addr, uint16_t value, Instruction* instr) { PrintF("Unaligned unsigned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); } @@ -1310,7 +1309,7 @@ void Simulator::WriteH(int32_t addr, int16_t value, Instruction* instr) { PrintF("Unaligned halfword write at 0x%08x, pc=0x%08" V8PRIxPTR "\n", addr, reinterpret_cast(instr)); - OS::Abort(); + base::OS::Abort(); } @@ -2857,8 +2856,8 @@ int32_t Simulator::Call(byte* entry, int argument_count, ...) { // Compute position of stack on entry to generated code. int entry_stack = (original_stack - (argument_count - 4) * sizeof(int32_t) - kCArgsSlotsSize); - if (OS::ActivationFrameAlignment() != 0) { - entry_stack &= -OS::ActivationFrameAlignment(); + if (base::OS::ActivationFrameAlignment() != 0) { + entry_stack &= -base::OS::ActivationFrameAlignment(); } // Store remaining arguments on stack, from low to high memory. intptr_t* stack_argument = reinterpret_cast(entry_stack); diff --git a/src/mksnapshot.cc b/src/mksnapshot.cc index de6ffb8..69306e1 100644 --- a/src/mksnapshot.cc +++ b/src/mksnapshot.cc @@ -12,11 +12,11 @@ #include "src/v8.h" #include "src/assembler.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/flags.h" #include "src/list.h" #include "src/natives.h" -#include "src/platform.h" #include "src/serialize.h" @@ -134,7 +134,7 @@ class SnapshotWriter { void WriteFilePrefix() const { fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n"); fprintf(fp_, "#include \"src/v8.h\"\n"); - fprintf(fp_, "#include \"src/platform.h\"\n\n"); + fprintf(fp_, "#include \"src/base/platform/platform.h\"\n\n"); fprintf(fp_, "#include \"src/snapshot.h\"\n\n"); fprintf(fp_, "namespace v8 {\n"); fprintf(fp_, "namespace internal {\n\n"); @@ -231,7 +231,7 @@ class SnapshotWriter { } FILE* GetFileDescriptorOrDie(const char* filename) { - FILE* fp = i::OS::FOpen(filename, "wb"); + FILE* fp = base::OS::FOpen(filename, "wb"); if (fp == NULL) { i::PrintF("Unable to open file \"%s\" for writing.\n", filename); exit(1); @@ -363,7 +363,7 @@ int main(int argc, char** argv) { HandleScope scope(isolate); v8::Context::Scope cscope(v8::Local::New(isolate, context)); const char* name = i::FLAG_extra_code; - FILE* file = i::OS::FOpen(name, "rb"); + FILE* file = base::OS::FOpen(name, "rb"); if (file == NULL) { fprintf(stderr, "Failed to open '%s': errno %d\n", name, errno); exit(1); diff --git a/src/natives-external.cc b/src/natives-external.cc index e34f2e1..dc34cf0 100644 --- a/src/natives-external.cc +++ b/src/natives-external.cc @@ -4,7 +4,7 @@ #include "src/natives.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/list.h" #include "src/list-inl.h" #include "src/snapshot-source-sink.h" diff --git a/src/objects-inl.h b/src/objects-inl.h index 16d0acd..3a2fe93 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -2183,9 +2183,9 @@ inline double FixedDoubleArray::hole_nan_as_double() { inline double FixedDoubleArray::canonical_not_the_hole_nan_as_double() { - ASSERT(BitCast(OS::nan_value()) != kHoleNanInt64); - ASSERT((BitCast(OS::nan_value()) >> 32) != kHoleNanUpper32); - return OS::nan_value(); + ASSERT(BitCast(base::OS::nan_value()) != kHoleNanInt64); + ASSERT((BitCast(base::OS::nan_value()) >> 32) != kHoleNanUpper32); + return base::OS::nan_value(); } @@ -3952,11 +3952,11 @@ int32_t Int32ArrayTraits::defaultValue() { return 0; } float Float32ArrayTraits::defaultValue() { - return static_cast(OS::nan_value()); + return static_cast(base::OS::nan_value()); } -double Float64ArrayTraits::defaultValue() { return OS::nan_value(); } +double Float64ArrayTraits::defaultValue() { return base::OS::nan_value(); } template diff --git a/src/objects.cc b/src/objects.cc index aab918e..c0dde8d 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -10686,7 +10686,7 @@ void Code::Relocate(intptr_t delta) { for (RelocIterator it(this, RelocInfo::kApplyMask); !it.done(); it.next()) { it.rinfo()->apply(delta, SKIP_ICACHE_FLUSH); } - CPU::FlushICache(instruction_start(), instruction_size()); + CpuFeatures::FlushICache(instruction_start(), instruction_size()); } @@ -10740,7 +10740,7 @@ void Code::CopyFrom(const CodeDesc& desc) { it.rinfo()->apply(delta, SKIP_ICACHE_FLUSH); } } - CPU::FlushICache(instruction_start(), instruction_size()); + CpuFeatures::FlushICache(instruction_start(), instruction_size()); } @@ -15080,7 +15080,7 @@ Handle ExternalFloat32Array::SetValue( Handle array, uint32_t index, Handle value) { - float cast_value = static_cast(OS::nan_value()); + float cast_value = static_cast(base::OS::nan_value()); if (index < static_cast(array->length())) { if (value->IsSmi()) { int int_value = Handle::cast(value)->value(); @@ -15103,7 +15103,7 @@ Handle ExternalFloat64Array::SetValue( Handle array, uint32_t index, Handle value) { - double double_value = OS::nan_value(); + double double_value = base::OS::nan_value(); if (index < static_cast(array->length())) { if (value->IsNumber()) { double_value = value->Number(); diff --git a/src/objects.h b/src/objects.h index a494778..ef3cd34 100644 --- a/src/objects.h +++ b/src/objects.h @@ -8,6 +8,7 @@ #include "src/allocation.h" #include "src/assert-scope.h" #include "src/builtins.h" +#include "src/checks.h" #include "src/elements-kind.h" #include "src/field-index.h" #include "src/flags.h" @@ -15,7 +16,6 @@ #include "src/property-details.h" #include "src/smart-pointers.h" #include "src/unicode-inl.h" -#include "src/v8checks.h" #include "src/zone.h" #if V8_TARGET_ARCH_ARM diff --git a/src/optimizing-compiler-thread.cc b/src/optimizing-compiler-thread.cc index 987bac2..5a048c4 100644 --- a/src/optimizing-compiler-thread.cc +++ b/src/optimizing-compiler-thread.cc @@ -31,7 +31,7 @@ OptimizingCompilerThread::~OptimizingCompilerThread() { void OptimizingCompilerThread::Run() { #ifdef DEBUG - { LockGuard lock_guard(&thread_id_mutex_); + { base::LockGuard lock_guard(&thread_id_mutex_); thread_id_ = ThreadId::Current().ToInteger(); } #endif @@ -40,7 +40,7 @@ void OptimizingCompilerThread::Run() { DisallowHandleAllocation no_handles; DisallowHandleDereference no_deref; - ElapsedTimer total_timer; + base::ElapsedTimer total_timer; if (FLAG_trace_concurrent_recompilation) total_timer.Start(); while (true) { @@ -49,7 +49,7 @@ void OptimizingCompilerThread::Run() { isolate_, Logger::TimerEventScope::v8_recompile_concurrent); if (FLAG_concurrent_recompilation_delay != 0) { - OS::Sleep(FLAG_concurrent_recompilation_delay); + base::OS::Sleep(FLAG_concurrent_recompilation_delay); } switch (static_cast(base::Acquire_Load(&stop_thread_))) { @@ -73,7 +73,7 @@ void OptimizingCompilerThread::Run() { continue; } - ElapsedTimer compiling_timer; + base::ElapsedTimer compiling_timer; if (FLAG_trace_concurrent_recompilation) compiling_timer.Start(); CompileNext(); @@ -86,7 +86,7 @@ void OptimizingCompilerThread::Run() { OptimizedCompileJob* OptimizingCompilerThread::NextInput() { - LockGuard access_input_queue_(&input_queue_mutex_); + base::LockGuard access_input_queue_(&input_queue_mutex_); if (input_queue_length_ == 0) return NULL; OptimizedCompileJob* job = input_queue_[InputQueueIndex(0)]; ASSERT_NE(NULL, job); @@ -257,7 +257,7 @@ void OptimizingCompilerThread::QueueForOptimization(OptimizedCompileJob* job) { osr_attempts_++; AddToOsrBuffer(job); // Add job to the front of the input queue. - LockGuard access_input_queue(&input_queue_mutex_); + base::LockGuard access_input_queue(&input_queue_mutex_); ASSERT_LT(input_queue_length_, input_queue_capacity_); // Move shift_ back by one. input_queue_shift_ = InputQueueIndex(input_queue_capacity_ - 1); @@ -265,7 +265,7 @@ void OptimizingCompilerThread::QueueForOptimization(OptimizedCompileJob* job) { input_queue_length_++; } else { // Add job to the back of the input queue. - LockGuard access_input_queue(&input_queue_mutex_); + base::LockGuard access_input_queue(&input_queue_mutex_); ASSERT_LT(input_queue_length_, input_queue_capacity_); input_queue_[InputQueueIndex(input_queue_length_)] = job; input_queue_length_++; @@ -364,7 +364,7 @@ bool OptimizingCompilerThread::IsOptimizerThread(Isolate* isolate) { bool OptimizingCompilerThread::IsOptimizerThread() { - LockGuard lock_guard(&thread_id_mutex_); + base::LockGuard lock_guard(&thread_id_mutex_); return ThreadId::Current().ToInteger() == thread_id_; } #endif diff --git a/src/optimizing-compiler-thread.h b/src/optimizing-compiler-thread.h index a6bcbed..941ddcd 100644 --- a/src/optimizing-compiler-thread.h +++ b/src/optimizing-compiler-thread.h @@ -6,11 +6,11 @@ #define V8_OPTIMIZING_COMPILER_THREAD_H_ #include "src/base/atomicops.h" +#include "src/base/platform/mutex.h" +#include "src/base/platform/platform.h" +#include "src/base/platform/time.h" #include "src/flags.h" #include "src/list.h" -#include "src/platform.h" -#include "src/platform/mutex.h" -#include "src/platform/time.h" #include "src/unbound-queue-inl.h" namespace v8 { @@ -20,7 +20,7 @@ class HOptimizedGraphBuilder; class OptimizedCompileJob; class SharedFunctionInfo; -class OptimizingCompilerThread : public Thread { +class OptimizingCompilerThread : public base::Thread { public: explicit OptimizingCompilerThread(Isolate *isolate) : Thread("OptimizingCompilerThread"), @@ -63,7 +63,7 @@ class OptimizingCompilerThread : public Thread { bool IsQueuedForOSR(JSFunction* function); inline bool IsQueueAvailable() { - LockGuard access_input_queue(&input_queue_mutex_); + base::LockGuard access_input_queue(&input_queue_mutex_); return input_queue_length_ < input_queue_capacity_; } @@ -105,19 +105,19 @@ class OptimizingCompilerThread : public Thread { #ifdef DEBUG int thread_id_; - Mutex thread_id_mutex_; + base::Mutex thread_id_mutex_; #endif Isolate* isolate_; - Semaphore stop_semaphore_; - Semaphore input_queue_semaphore_; + base::Semaphore stop_semaphore_; + base::Semaphore input_queue_semaphore_; // Circular queue of incoming recompilation tasks (including OSR). OptimizedCompileJob** input_queue_; int input_queue_capacity_; int input_queue_length_; int input_queue_shift_; - Mutex input_queue_mutex_; + base::Mutex input_queue_mutex_; // Queue of recompilation tasks ready to be installed (excluding OSR). UnboundQueue output_queue_; @@ -128,8 +128,8 @@ class OptimizingCompilerThread : public Thread { int osr_buffer_cursor_; volatile base::AtomicWord stop_thread_; - TimeDelta time_spent_compiling_; - TimeDelta time_spent_total_; + base::TimeDelta time_spent_compiling_; + base::TimeDelta time_spent_total_; int osr_hits_; int osr_attempts_; diff --git a/src/parser.cc b/src/parser.cc index a2900b5..a04db36 100644 --- a/src/parser.cc +++ b/src/parser.cc @@ -6,13 +6,13 @@ #include "src/api.h" #include "src/ast.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/char-predicates-inl.h" #include "src/codegen.h" #include "src/compiler.h" #include "src/messages.h" #include "src/parser.h" -#include "src/platform.h" #include "src/preparser.h" #include "src/runtime.h" #include "src/scanner-character-streams.h" @@ -792,7 +792,7 @@ FunctionLiteral* Parser::ParseProgram() { HistogramTimerScope timer_scope(isolate()->counters()->parse(), true); Handle source(String::cast(script_->source())); isolate()->counters()->total_parse_size()->Increment(source->length()); - ElapsedTimer timer; + base::ElapsedTimer timer; if (FLAG_trace_parse) { timer.Start(); } @@ -947,7 +947,7 @@ FunctionLiteral* Parser::ParseLazy() { HistogramTimerScope timer_scope(isolate()->counters()->parse_lazy()); Handle source(String::cast(script_->source())); isolate()->counters()->total_parse_size()->Increment(source->length()); - ElapsedTimer timer; + base::ElapsedTimer timer; if (FLAG_trace_parse) { timer.Start(); } diff --git a/src/preparse-data.cc b/src/preparse-data.cc index 477a46f..50e9120 100644 --- a/src/preparse-data.cc +++ b/src/preparse-data.cc @@ -3,7 +3,7 @@ // found in the LICENSE file. #include "include/v8stdint.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/globals.h" #include "src/hashmap.h" #include "src/preparse-data.h" diff --git a/src/preparser.cc b/src/preparser.cc index 688962d..df9e48e 100644 --- a/src/preparser.cc +++ b/src/preparser.cc @@ -7,7 +7,7 @@ #include "include/v8stdint.h" #include "src/allocation.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/conversions-inl.h" #include "src/conversions.h" #include "src/globals.h" diff --git a/src/prettyprinter.cc b/src/prettyprinter.cc index c0961f2..f1b30ed 100644 --- a/src/prettyprinter.cc +++ b/src/prettyprinter.cc @@ -7,7 +7,7 @@ #include "src/v8.h" #include "src/ast-value-factory.h" -#include "src/platform.h" +#include "src/base/platform/platform.h" #include "src/prettyprinter.h" #include "src/scopes.h" diff --git a/src/profile-generator.cc b/src/profile-generator.cc index 70559e9..945bdd6 100644 --- a/src/profile-generator.cc +++ b/src/profile-generator.cc @@ -208,17 +208,12 @@ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) { void ProfileNode::Print(int indent) { - OS::Print("%5u %*s %s%s %d #%d %s", - self_ticks_, - indent, "", - entry_->name_prefix(), - entry_->name(), - entry_->script_id(), - id(), - entry_->bailout_reason()); + base::OS::Print("%5u %*s %s%s %d #%d %s", self_ticks_, indent, "", + entry_->name_prefix(), entry_->name(), entry_->script_id(), + id(), entry_->bailout_reason()); if (entry_->resource_name()[0] != '\0') - OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); - OS::Print("\n"); + base::OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number()); + base::OS::Print("\n"); for (HashMap::Entry* p = children_.Start(); p != NULL; p = children_.Next(p)) { @@ -332,11 +327,12 @@ void ProfileTree::TraverseDepthFirst(Callback* callback) { CpuProfile::CpuProfile(const char* title, bool record_samples) : title_(title), record_samples_(record_samples), - start_time_(TimeTicks::HighResolutionNow()) { + start_time_(base::TimeTicks::HighResolutionNow()) { } -void CpuProfile::AddPath(TimeTicks timestamp, const Vector& path) { +void CpuProfile::AddPath(base::TimeTicks timestamp, + const Vector& path) { ProfileNode* top_frame_node = top_down_.AddPathFromEnd(path); if (record_samples_) { timestamps_.Add(timestamp); @@ -346,12 +342,12 @@ void CpuProfile::AddPath(TimeTicks timestamp, const Vector& path) { void CpuProfile::CalculateTotalTicksAndSamplingRate() { - end_time_ = TimeTicks::HighResolutionNow(); + end_time_ = base::TimeTicks::HighResolutionNow(); } void CpuProfile::Print() { - OS::Print("[Top down]:\n"); + base::OS::Print("[Top down]:\n"); top_down_.Print(); } @@ -428,9 +424,9 @@ void CodeMap::CodeTreePrinter::Call( const Address& key, const CodeMap::CodeEntryInfo& value) { // For shared function entries, 'size' field is used to store their IDs. if (value.entry == kSharedFunctionCodeEntry) { - OS::Print("%p SharedFunctionInfo %d\n", key, value.size); + base::OS::Print("%p SharedFunctionInfo %d\n", key, value.size); } else { - OS::Print("%p %5d %s\n", key, value.size, value.entry->name()); + base::OS::Print("%p %5d %s\n", key, value.size, value.entry->name()); } } @@ -525,7 +521,7 @@ void CpuProfilesCollection::RemoveProfile(CpuProfile* profile) { void CpuProfilesCollection::AddPathToCurrentProfiles( - TimeTicks timestamp, const Vector& path) { + base::TimeTicks timestamp, const Vector& path) { // As starting / stopping profiles is rare relatively to this // method, we don't bother minimizing the duration of lock holding, // e.g. copying contents of the list to a local vector. diff --git a/src/profile-generator.h b/src/profile-generator.h index 9e8be87..1fb2a46 100644 --- a/src/profile-generator.h +++ b/src/profile-generator.h @@ -176,7 +176,7 @@ class CpuProfile { CpuProfile(const char* title, bool record_samples); // Add pc -> ... -> main() call path to the profile. - void AddPath(TimeTicks timestamp, const Vector& path); + void AddPath(base::TimeTicks timestamp, const Vector& path); void CalculateTotalTicksAndSamplingRate(); const char* title() const { return title_; } @@ -184,10 +184,12 @@ class CpuProfile { int samples_count() const { return samples_.length(); } ProfileNode* sample(int index) const { return samples_.at(index); } - TimeTicks sample_timestamp(int index) const { return timestamps_.at(index); } + base::TimeTicks sample_timestamp(int index) const { + return timestamps_.at(index); + } - TimeTicks start_time() const { return start_time_; } - TimeTicks end_time() const { return end_time_; } + base::TimeTicks start_time() const { return start_time_; } + base::TimeTicks end_time() const { return end_time_; } void UpdateTicksScale(); @@ -196,10 +198,10 @@ class CpuProfile { private: const char* title_; bool record_samples_; - TimeTicks start_time_; - TimeTicks end_time_; + base::TimeTicks start_time_; + base::TimeTicks end_time_; List samples_; - List timestamps_; + List timestamps_; ProfileTree top_down_; DISALLOW_COPY_AND_ASSIGN(CpuProfile); @@ -285,7 +287,7 @@ class CpuProfilesCollection { // Called from profile generator thread. void AddPathToCurrentProfiles( - TimeTicks timestamp, const Vector& path); + base::TimeTicks timestamp, const Vector& path); // Limits the number of profiles that can be simultaneously collected. static const int kMaxSimultaneousProfiles = 100; @@ -297,7 +299,7 @@ class CpuProfilesCollection { // Accessed by VM thread and profile generator thread. List current_profiles_; - Semaphore current_profiles_semaphore_; + base::Semaphore current_profiles_semaphore_; DISALLOW_COPY_AND_ASSIGN(CpuProfilesCollection); }; diff --git a/src/runtime-profiler.cc b/src/runtime-profiler.cc index cba563f..afbda62 100644 --- a/src/runtime-profiler.cc +++ b/src/runtime-profiler.cc @@ -7,6 +7,7 @@ #include "src/runtime-profiler.h" #include "src/assembler.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/code-stubs.h" #include "src/compilation-cache.h" @@ -15,7 +16,6 @@ #include "src/global-handles.h" #include "src/isolate-inl.h" #include "src/mark-compact.h" -#include "src/platform.h" #include "src/scopeinfo.h" namespace v8 { diff --git a/src/runtime-profiler.h b/src/runtime-profiler.h index 14ced76..eff443d 100644 --- a/src/runtime-profiler.h +++ b/src/runtime-profiler.h @@ -8,12 +8,16 @@ #include "src/allocation.h" namespace v8 { + +namespace base { +class Semaphore; +} + namespace internal { class Isolate; class JSFunction; class Object; -class Semaphore; class RuntimeProfiler { public: diff --git a/src/runtime.cc b/src/runtime.cc index f341d14..5efaaa1 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -11,12 +11,13 @@ #include "src/allocation-site-scopes.h" #include "src/api.h" #include "src/arguments.h" +#include "src/base/cpu.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/codegen.h" #include "src/compilation-cache.h" #include "src/compiler.h" #include "src/conversions.h" -#include "src/cpu.h" #include "src/cpu-profiler.h" #include "src/date.h" #include "src/dateparser-inl.h" @@ -33,7 +34,6 @@ #include "src/liveedit.h" #include "src/misc-intrinsics.h" #include "src/parser.h" -#include "src/platform.h" #include "src/runtime.h" #include "src/runtime-profiler.h" #include "src/scopeinfo.h" @@ -6288,8 +6288,8 @@ RUNTIME_FUNCTION(Runtime_StringParseFloat) { CONVERT_ARG_HANDLE_CHECKED(String, subject, 0); subject = String::Flatten(subject); - double value = StringToDouble( - isolate->unicode_cache(), *subject, ALLOW_TRAILING_JUNK, OS::nan_value()); + double value = StringToDouble(isolate->unicode_cache(), *subject, + ALLOW_TRAILING_JUNK, base::OS::nan_value()); return *isolate->factory()->NewNumber(value); } @@ -8564,7 +8564,7 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { sync_with_compiler_thread) { while (function->IsInOptimizationQueue()) { isolate->optimizing_compiler_thread()->InstallOptimizedFunctions(); - OS::Sleep(50); + base::OS::Sleep(50); } } if (FLAG_always_opt) { @@ -9551,7 +9551,7 @@ RUNTIME_FUNCTION(Runtime_DateCurrentTime) { millis = 1388534400000.0; // Jan 1 2014 00:00:00 GMT+0000 millis += std::floor(isolate->heap()->synthetic_time()); } else { - millis = std::floor(OS::TimeCurrentMillis()); + millis = std::floor(base::OS::TimeCurrentMillis()); } return *isolate->factory()->NewNumber(millis); } @@ -13207,7 +13207,7 @@ RUNTIME_FUNCTION(Runtime_DebugSetScriptSource) { RUNTIME_FUNCTION(Runtime_SystemBreak) { SealHandleScope shs(isolate); ASSERT(args.length() == 0); - OS::DebugBreak(); + base::OS::DebugBreak(); return isolate->heap()->undefined_value(); } @@ -14472,9 +14472,9 @@ RUNTIME_FUNCTION(Runtime_Abort) { CONVERT_SMI_ARG_CHECKED(message_id, 0); const char* message = GetBailoutReason( static_cast(message_id)); - OS::PrintError("abort: %s\n", message); + base::OS::PrintError("abort: %s\n", message); isolate->PrintStack(stderr); - OS::Abort(); + base::OS::Abort(); UNREACHABLE(); return NULL; } @@ -14484,9 +14484,9 @@ RUNTIME_FUNCTION(Runtime_AbortJS) { HandleScope scope(isolate); ASSERT(args.length() == 1); CONVERT_ARG_HANDLE_CHECKED(String, message, 0); - OS::PrintError("abort: %s\n", message->ToCString().get()); + base::OS::PrintError("abort: %s\n", message->ToCString().get()); isolate->PrintStack(stderr); - OS::Abort(); + base::OS::Abort(); UNREACHABLE(); return NULL; } diff --git a/src/sampler.cc b/src/sampler.cc index 82fe27d..7ee7216 100644 --- a/src/sampler.cc +++ b/src/sampler.cc @@ -44,11 +44,11 @@ #include "src/v8.h" +#include "src/base/platform/platform.h" #include "src/cpu-profiler-inl.h" #include "src/flags.h" #include "src/frames-inl.h" #include "src/log.h" -#include "src/platform.h" #include "src/simulator.h" #include "src/v8threads.h" #include "src/vm-state-inl.h" @@ -269,16 +269,16 @@ class SimulatorHelper { class SignalHandler : public AllStatic { public: - static void SetUp() { if (!mutex_) mutex_ = new Mutex(); } + static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); } static void TearDown() { delete mutex_; } static void IncreaseSamplerCount() { - LockGuard lock_guard(mutex_); + base::LockGuard lock_guard(mutex_); if (++client_count_ == 1) Install(); } static void DecreaseSamplerCount() { - LockGuard lock_guard(mutex_); + base::LockGuard lock_guard(mutex_); if (--client_count_ == 0) Restore(); } @@ -309,14 +309,14 @@ class SignalHandler : public AllStatic { static void HandleProfilerSignal(int signal, siginfo_t* info, void* context); // Protects the process wide state below. - static Mutex* mutex_; + static base::Mutex* mutex_; static int client_count_; static bool signal_handler_installed_; static struct sigaction old_signal_handler_; }; -Mutex* SignalHandler::mutex_ = NULL; +base::Mutex* SignalHandler::mutex_ = NULL; int SignalHandler::client_count_ = 0; struct sigaction SignalHandler::old_signal_handler_; bool SignalHandler::signal_handler_installed_ = false; @@ -473,20 +473,20 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, #endif -class SamplerThread : public Thread { +class SamplerThread : public base::Thread { public: static const int kSamplerThreadStackSize = 64 * KB; explicit SamplerThread(int interval) - : Thread(Thread::Options("SamplerThread", kSamplerThreadStackSize)), + : Thread(base::Thread::Options("SamplerThread", kSamplerThreadStackSize)), interval_(interval) {} - static void SetUp() { if (!mutex_) mutex_ = new Mutex(); } + static void SetUp() { if (!mutex_) mutex_ = new base::Mutex(); } static void TearDown() { delete mutex_; mutex_ = NULL; } static void AddActiveSampler(Sampler* sampler) { bool need_to_start = false; - LockGuard lock_guard(mutex_); + base::LockGuard lock_guard(mutex_); if (instance_ == NULL) { // Start a thread that will send SIGPROF signal to VM threads, // when CPU profiling will be enabled. @@ -505,7 +505,7 @@ class SamplerThread : public Thread { static void RemoveActiveSampler(Sampler* sampler) { SamplerThread* instance_to_remove = NULL; { - LockGuard lock_guard(mutex_); + base::LockGuard lock_guard(mutex_); ASSERT(sampler->IsActive()); bool removed = instance_->active_samplers_.RemoveElement(sampler); @@ -529,7 +529,7 @@ class SamplerThread : public Thread { virtual void Run() { while (true) { { - LockGuard lock_guard(mutex_); + base::LockGuard lock_guard(mutex_); if (active_samplers_.is_empty()) break; // When CPU profiling is enabled both JavaScript and C++ code is // profiled. We must not suspend. @@ -540,13 +540,13 @@ class SamplerThread : public Thread { sampler->DoSample(); } } - OS::Sleep(interval_); + base::OS::Sleep(interval_); } } private: // Protects the process wide state below. - static Mutex* mutex_; + static base::Mutex* mutex_; static SamplerThread* instance_; const int interval_; @@ -556,7 +556,7 @@ class SamplerThread : public Thread { }; -Mutex* SamplerThread::mutex_ = NULL; +base::Mutex* SamplerThread::mutex_ = NULL; SamplerThread* SamplerThread::instance_ = NULL; @@ -566,7 +566,7 @@ SamplerThread* SamplerThread::instance_ = NULL; DISABLE_ASAN void TickSample::Init(Isolate* isolate, const RegisterState& regs) { ASSERT(isolate->IsInitialized()); - timestamp = TimeTicks::HighResolutionNow(); + timestamp = base::TimeTicks::HighResolutionNow(); pc = regs.pc; state = isolate->current_vm_state(); diff --git a/src/sampler.h b/src/sampler.h index 80fe5a9..c3dce4e 100644 --- a/src/sampler.h +++ b/src/sampler.h @@ -47,7 +47,7 @@ struct TickSample { static const unsigned kMaxFramesCountLog2 = 8; static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; Address stack[kMaxFramesCount]; // Call stack. - TimeTicks timestamp; + base::TimeTicks timestamp; unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. bool has_external_callback : 1; StackFrame::Type top_frame_type : 4; diff --git a/src/scanner.h b/src/scanner.h index 8fee1b1..6e7dabc 100644 --- a/src/scanner.h +++ b/src/scanner.h @@ -8,8 +8,8 @@ #define V8_SCANNER_H_ #include "src/allocation.h" +#include "src/base/logging.h" #include "src/char-predicates.h" -#include "src/checks.h" #include "src/globals.h" #include "src/hashmap.h" #include "src/list.h" diff --git a/src/serialize.cc b/src/serialize.cc index 07f77ff..769e645 100644 --- a/src/serialize.cc +++ b/src/serialize.cc @@ -6,13 +6,13 @@ #include "src/accessors.h" #include "src/api.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/deoptimizer.h" #include "src/execution.h" #include "src/global-handles.h" #include "src/ic-inl.h" #include "src/natives.h" -#include "src/platform.h" #include "src/runtime.h" #include "src/serialize.h" #include "src/snapshot.h" @@ -729,7 +729,7 @@ void Deserializer::FlushICacheForNewCodeObjects() { PageIterator it(isolate_->heap()->code_space()); while (it.has_next()) { Page* p = it.next(); - CPU::FlushICache(p->area_start(), p->area_end() - p->area_start()); + CpuFeatures::FlushICache(p->area_start(), p->area_end() - p->area_start()); } } diff --git a/src/small-pointer-list.h b/src/small-pointer-list.h index c4f8233..065ca91 100644 --- a/src/small-pointer-list.h +++ b/src/small-pointer-list.h @@ -5,7 +5,7 @@ #ifndef V8_SMALL_POINTER_LIST_H_ #define V8_SMALL_POINTER_LIST_H_ -#include "src/checks.h" +#include "src/base/logging.h" #include "src/globals.h" #include "src/zone.h" diff --git a/src/snapshot-common.cc b/src/snapshot-common.cc index 965f1bf..25193b2 100644 --- a/src/snapshot-common.cc +++ b/src/snapshot-common.cc @@ -7,7 +7,7 @@ #include "src/v8.h" #include "src/api.h" -#include "src/platform.h" +#include "src/base/platform/platform.h" #include "src/serialize.h" #include "src/snapshot.h" @@ -28,7 +28,7 @@ void Snapshot::ReserveSpaceForLinkedInSnapshot(Deserializer* deserializer) { bool Snapshot::Initialize() { if (size_ > 0) { - ElapsedTimer timer; + base::ElapsedTimer timer; if (FLAG_profile_deserialization) { timer.Start(); } diff --git a/src/snapshot-source-sink.cc b/src/snapshot-source-sink.cc index 9e6e604..146f949 100644 --- a/src/snapshot-source-sink.cc +++ b/src/snapshot-source-sink.cc @@ -4,8 +4,8 @@ #include "src/snapshot-source-sink.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/handles-inl.h" #include "src/serialize.h" // for SerializerDeserializer::nop() in AtEOF() diff --git a/src/snapshot-source-sink.h b/src/snapshot-source-sink.h index 0911e7c..6e2328c 100644 --- a/src/snapshot-source-sink.h +++ b/src/snapshot-source-sink.h @@ -5,7 +5,7 @@ #ifndef V8_SNAPSHOT_SOURCE_SINK_H_ #define V8_SNAPSHOT_SOURCE_SINK_H_ -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" namespace v8 { diff --git a/src/spaces-inl.h b/src/spaces-inl.h index 5f024e4..d9118c8 100644 --- a/src/spaces-inl.h +++ b/src/spaces-inl.h @@ -109,27 +109,27 @@ HeapObject* HeapObjectIterator::FromCurrentPage() { #ifdef ENABLE_HEAP_PROTECTION void MemoryAllocator::Protect(Address start, size_t size) { - OS::Protect(start, size); + base::OS::Protect(start, size); } void MemoryAllocator::Unprotect(Address start, size_t size, Executability executable) { - OS::Unprotect(start, size, executable); + base::OS::Unprotect(start, size, executable); } void MemoryAllocator::ProtectChunkFromPage(Page* page) { int id = GetChunkId(page); - OS::Protect(chunks_[id].address(), chunks_[id].size()); + base::OS::Protect(chunks_[id].address(), chunks_[id].size()); } void MemoryAllocator::UnprotectChunkFromPage(Page* page) { int id = GetChunkId(page); - OS::Unprotect(chunks_[id].address(), chunks_[id].size(), - chunks_[id].owner()->executable() == EXECUTABLE); + base::OS::Unprotect(chunks_[id].address(), chunks_[id].size(), + chunks_[id].owner()->executable() == EXECUTABLE); } #endif diff --git a/src/spaces.cc b/src/spaces.cc index 69a0145..300d19e 100644 --- a/src/spaces.cc +++ b/src/spaces.cc @@ -4,11 +4,11 @@ #include "src/v8.h" +#include "src/base/platform/platform.h" #include "src/full-codegen.h" #include "src/macro-assembler.h" #include "src/mark-compact.h" #include "src/msan.h" -#include "src/platform.h" namespace v8 { namespace internal { @@ -126,7 +126,7 @@ bool CodeRange::SetUp(size_t requested) { } ASSERT(!kRequiresCodeRange || requested <= kMaximalCodeRangeSize); - code_range_ = new VirtualMemory(requested); + code_range_ = new base::VirtualMemory(requested); CHECK(code_range_ != NULL); if (!code_range_->IsReserved()) { delete code_range_; @@ -301,7 +301,8 @@ void MemoryAllocator::TearDown() { bool MemoryAllocator::CommitMemory(Address base, size_t size, Executability executable) { - if (!VirtualMemory::CommitRegion(base, size, executable == EXECUTABLE)) { + if (!base::VirtualMemory::CommitRegion(base, size, + executable == EXECUTABLE)) { return false; } UpdateAllocatedSpaceLimits(base, base + size); @@ -309,7 +310,7 @@ bool MemoryAllocator::CommitMemory(Address base, } -void MemoryAllocator::FreeMemory(VirtualMemory* reservation, +void MemoryAllocator::FreeMemory(base::VirtualMemory* reservation, Executability executable) { // TODO(gc) make code_range part of memory allocator? ASSERT(reservation->IsReserved()); @@ -355,7 +356,7 @@ void MemoryAllocator::FreeMemory(Address base, ASSERT(executable == NOT_EXECUTABLE || isolate_->code_range() == NULL || !isolate_->code_range()->valid()); - bool result = VirtualMemory::ReleaseRegion(base, size); + bool result = base::VirtualMemory::ReleaseRegion(base, size); USE(result); ASSERT(result); } @@ -364,8 +365,8 @@ void MemoryAllocator::FreeMemory(Address base, Address MemoryAllocator::ReserveAlignedMemory(size_t size, size_t alignment, - VirtualMemory* controller) { - VirtualMemory reservation(size, alignment); + base::VirtualMemory* controller) { + base::VirtualMemory reservation(size, alignment); if (!reservation.IsReserved()) return NULL; size_ += reservation.size(); @@ -376,13 +377,11 @@ Address MemoryAllocator::ReserveAlignedMemory(size_t size, } -Address MemoryAllocator::AllocateAlignedMemory(size_t reserve_size, - size_t commit_size, - size_t alignment, - Executability executable, - VirtualMemory* controller) { +Address MemoryAllocator::AllocateAlignedMemory( + size_t reserve_size, size_t commit_size, size_t alignment, + Executability executable, base::VirtualMemory* controller) { ASSERT(commit_size <= reserve_size); - VirtualMemory reservation; + base::VirtualMemory reservation; Address base = ReserveAlignedMemory(reserve_size, alignment, &reservation); if (base == NULL) return NULL; @@ -511,9 +510,10 @@ bool MemoryChunk::CommitArea(size_t requested) { size_t guard_size = IsFlagSet(IS_EXECUTABLE) ? MemoryAllocator::CodePageGuardSize() : 0; size_t header_size = area_start() - address() - guard_size; - size_t commit_size = RoundUp(header_size + requested, OS::CommitPageSize()); + size_t commit_size = + RoundUp(header_size + requested, base::OS::CommitPageSize()); size_t committed_size = RoundUp(header_size + (area_end() - area_start()), - OS::CommitPageSize()); + base::OS::CommitPageSize()); if (commit_size > committed_size) { // Commit size should be less or equal than the reserved size. @@ -587,7 +587,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, size_t chunk_size; Heap* heap = isolate_->heap(); Address base = NULL; - VirtualMemory reservation; + base::VirtualMemory reservation; Address area_start = NULL; Address area_end = NULL; @@ -623,7 +623,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, if (executable == EXECUTABLE) { chunk_size = RoundUp(CodePageAreaStartOffset() + reserve_area_size, - OS::CommitPageSize()) + CodePageGuardSize(); + base::OS::CommitPageSize()) + CodePageGuardSize(); // Check executable memory limit. if (size_executable_ + chunk_size > capacity_executable_) { @@ -635,7 +635,7 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, // Size of header (not executable) plus area (executable). size_t commit_size = RoundUp(CodePageGuardStartOffset() + commit_area_size, - OS::CommitPageSize()); + base::OS::CommitPageSize()); // Allocate executable memory either from code range or from the // OS. if (isolate_->code_range() != NULL && isolate_->code_range()->valid()) { @@ -668,9 +668,9 @@ MemoryChunk* MemoryAllocator::AllocateChunk(intptr_t reserve_area_size, area_end = area_start + commit_area_size; } else { chunk_size = RoundUp(MemoryChunk::kObjectStartOffset + reserve_area_size, - OS::CommitPageSize()); + base::OS::CommitPageSize()); size_t commit_size = RoundUp(MemoryChunk::kObjectStartOffset + - commit_area_size, OS::CommitPageSize()); + commit_area_size, base::OS::CommitPageSize()); base = AllocateAlignedMemory(chunk_size, commit_size, MemoryChunk::kAlignment, @@ -757,7 +757,7 @@ void MemoryAllocator::Free(MemoryChunk* chunk) { delete chunk->slots_buffer(); delete chunk->skip_list(); - VirtualMemory* reservation = chunk->reserved_memory(); + base::VirtualMemory* reservation = chunk->reserved_memory(); if (reservation->IsReserved()) { FreeMemory(reservation, chunk->executable()); } else { @@ -783,7 +783,7 @@ bool MemoryAllocator::CommitBlock(Address start, bool MemoryAllocator::UncommitBlock(Address start, size_t size) { - if (!VirtualMemory::UncommitRegion(start, size)) return false; + if (!base::VirtualMemory::UncommitRegion(start, size)) return false; isolate_->counters()->memory_allocated()->Decrement(static_cast(size)); return true; } @@ -856,12 +856,12 @@ void MemoryAllocator::ReportStatistics() { int MemoryAllocator::CodePageGuardStartOffset() { // We are guarding code pages: the first OS page after the header // will be protected as non-writable. - return RoundUp(Page::kObjectStartOffset, OS::CommitPageSize()); + return RoundUp(Page::kObjectStartOffset, base::OS::CommitPageSize()); } int MemoryAllocator::CodePageGuardSize() { - return static_cast(OS::CommitPageSize()); + return static_cast(base::OS::CommitPageSize()); } @@ -875,11 +875,11 @@ int MemoryAllocator::CodePageAreaStartOffset() { int MemoryAllocator::CodePageAreaEndOffset() { // We are guarding code pages: the last OS page will be protected as // non-writable. - return Page::kPageSize - static_cast(OS::CommitPageSize()); + return Page::kPageSize - static_cast(base::OS::CommitPageSize()); } -bool MemoryAllocator::CommitExecutableMemory(VirtualMemory* vm, +bool MemoryAllocator::CommitExecutableMemory(base::VirtualMemory* vm, Address start, size_t commit_size, size_t reserved_size) { @@ -977,7 +977,7 @@ void PagedSpace::TearDown() { size_t PagedSpace::CommittedPhysicalMemory() { - if (!VirtualMemory::HasLazyCommits()) return CommittedMemory(); + if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); size_t size = 0; PageIterator it(this); @@ -1587,7 +1587,7 @@ bool SemiSpace::GrowTo(int new_capacity) { size_t delta = new_capacity - capacity_; - ASSERT(IsAligned(delta, OS::AllocateAlignment())); + ASSERT(IsAligned(delta, base::OS::AllocateAlignment())); if (!heap()->isolate()->memory_allocator()->CommitBlock( start_ + capacity_, delta, executable())) { return false; @@ -1617,7 +1617,7 @@ bool SemiSpace::ShrinkTo(int new_capacity) { ASSERT(new_capacity < capacity_); if (is_committed()) { size_t delta = capacity_ - new_capacity; - ASSERT(IsAligned(delta, OS::AllocateAlignment())); + ASSERT(IsAligned(delta, base::OS::AllocateAlignment())); MemoryAllocator* allocator = heap()->isolate()->memory_allocator(); if (!allocator->UncommitBlock(start_ + new_capacity, delta)) { @@ -1983,7 +1983,7 @@ void NewSpace::RecordPromotion(HeapObject* obj) { size_t NewSpace::CommittedPhysicalMemory() { - if (!VirtualMemory::HasLazyCommits()) return CommittedMemory(); + if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); MemoryChunk::UpdateHighWaterMark(allocation_info_.top()); size_t size = to_space_.CommittedPhysicalMemory(); if (from_space_.is_committed()) { @@ -2075,8 +2075,8 @@ intptr_t FreeListCategory::Concatenate(FreeListCategory* category) { // This is safe (not going to deadlock) since Concatenate operations // are never performed on the same free lists at the same time in // reverse order. - LockGuard target_lock_guard(mutex()); - LockGuard source_lock_guard(category->mutex()); + base::LockGuard target_lock_guard(mutex()); + base::LockGuard source_lock_guard(category->mutex()); ASSERT(category->end_ != NULL); free_bytes = category->available(); if (end_ == NULL) { @@ -2925,7 +2925,7 @@ AllocationResult LargeObjectSpace::AllocateRaw(int object_size, size_t LargeObjectSpace::CommittedPhysicalMemory() { - if (!VirtualMemory::HasLazyCommits()) return CommittedMemory(); + if (!base::VirtualMemory::HasLazyCommits()) return CommittedMemory(); size_t size = 0; LargePage* current = first_page_; while (current != NULL) { diff --git a/src/spaces.h b/src/spaces.h index 9127d2c..a940eed 100644 --- a/src/spaces.h +++ b/src/spaces.h @@ -7,10 +7,10 @@ #include "src/allocation.h" #include "src/base/atomicops.h" +#include "src/base/platform/mutex.h" #include "src/hashmap.h" #include "src/list.h" #include "src/log.h" -#include "src/platform/mutex.h" #include "src/utils.h" namespace v8 { @@ -328,7 +328,7 @@ class MemoryChunk { kFailureTag); } - VirtualMemory* reserved_memory() { + base::VirtualMemory* reserved_memory() { return &reservation_; } @@ -336,7 +336,7 @@ class MemoryChunk { reservation_.Reset(); } - void set_reserved_memory(VirtualMemory* reservation) { + void set_reserved_memory(base::VirtualMemory* reservation) { ASSERT_NOT_NULL(reservation); reservation_.TakeControl(reservation); } @@ -690,7 +690,7 @@ class MemoryChunk { Address area_end_; // If the chunk needs to remember its memory reservation, it is stored here. - VirtualMemory reservation_; + base::VirtualMemory reservation_; // The identity of the owning space. This is tagged as a failure pointer, but // no failure can be in an object, so this can be distinguished from any entry // in a fixed array. @@ -958,7 +958,7 @@ class CodeRange { Isolate* isolate_; // The reserved range of virtual memory that all code objects are put in. - VirtualMemory* code_range_; + base::VirtualMemory* code_range_; // Plain old data class, just a struct plus a constructor. class FreeBlock { public: @@ -1116,16 +1116,16 @@ class MemoryAllocator { Address ReserveAlignedMemory(size_t requested, size_t alignment, - VirtualMemory* controller); + base::VirtualMemory* controller); Address AllocateAlignedMemory(size_t reserve_size, size_t commit_size, size_t alignment, Executability executable, - VirtualMemory* controller); + base::VirtualMemory* controller); bool CommitMemory(Address addr, size_t size, Executability executable); - void FreeMemory(VirtualMemory* reservation, Executability executable); + void FreeMemory(base::VirtualMemory* reservation, Executability executable); void FreeMemory(Address addr, size_t size, Executability executable); // Commit a contiguous block of memory from the initial chunk. Assumes that @@ -1170,7 +1170,7 @@ class MemoryAllocator { return CodePageAreaEndOffset() - CodePageAreaStartOffset(); } - MUST_USE_RESULT bool CommitExecutableMemory(VirtualMemory* vm, + MUST_USE_RESULT bool CommitExecutableMemory(base::VirtualMemory* vm, Address start, size_t commit_size, size_t reserved_size); @@ -1551,7 +1551,7 @@ class FreeListCategory { int available() const { return available_; } void set_available(int available) { available_ = available; } - Mutex* mutex() { return &mutex_; } + base::Mutex* mutex() { return &mutex_; } bool IsEmpty() { return top() == 0; @@ -1566,7 +1566,7 @@ class FreeListCategory { // top_ points to the top FreeListNode* in the free list category. base::AtomicWord top_; FreeListNode* end_; - Mutex mutex_; + base::Mutex mutex_; // Total available bytes in all blocks of this free list category. int available_; @@ -2660,7 +2660,7 @@ class NewSpace : public Space { // The semispaces. SemiSpace to_space_; SemiSpace from_space_; - VirtualMemory reservation_; + base::VirtualMemory reservation_; int pages_used_; // Start address and bit mask for containment testing. diff --git a/src/store-buffer.cc b/src/store-buffer.cc index 5ec3e54..4ab5c33 100644 --- a/src/store-buffer.cc +++ b/src/store-buffer.cc @@ -37,7 +37,7 @@ StoreBuffer::StoreBuffer(Heap* heap) void StoreBuffer::SetUp() { - virtual_memory_ = new VirtualMemory(kStoreBufferSize * 3); + virtual_memory_ = new base::VirtualMemory(kStoreBufferSize * 3); uintptr_t start_as_int = reinterpret_cast(virtual_memory_->address()); start_ = @@ -45,13 +45,14 @@ void StoreBuffer::SetUp() { limit_ = start_ + (kStoreBufferSize / kPointerSize); old_virtual_memory_ = - new VirtualMemory(kOldStoreBufferLength * kPointerSize); + new base::VirtualMemory(kOldStoreBufferLength * kPointerSize); old_top_ = old_start_ = reinterpret_cast(old_virtual_memory_->address()); // Don't know the alignment requirements of the OS, but it is certainly not // less than 0xfff. ASSERT((reinterpret_cast(old_start_) & 0xfff) == 0); - int initial_length = static_cast(OS::CommitPageSize() / kPointerSize); + int initial_length = + static_cast(base::OS::CommitPageSize() / kPointerSize); ASSERT(initial_length > 0); ASSERT(initial_length <= kOldStoreBufferLength); old_limit_ = old_start_ + initial_length; diff --git a/src/store-buffer.h b/src/store-buffer.h index d6de2aa..00eb86a 100644 --- a/src/store-buffer.h +++ b/src/store-buffer.h @@ -6,9 +6,9 @@ #define V8_STORE_BUFFER_H_ #include "src/allocation.h" -#include "src/checks.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" #include "src/globals.h" -#include "src/platform.h" namespace v8 { namespace internal { @@ -119,7 +119,7 @@ class StoreBuffer { Address* old_limit_; Address* old_top_; Address* old_reserved_limit_; - VirtualMemory* old_virtual_memory_; + base::VirtualMemory* old_virtual_memory_; bool old_buffer_is_sorted_; bool old_buffer_is_filtered_; @@ -131,7 +131,7 @@ class StoreBuffer { StoreBufferCallback callback_; bool may_move_store_buffer_entries_; - VirtualMemory* virtual_memory_; + base::VirtualMemory* virtual_memory_; // Two hash sets used for filtering. // If address is in the hash set then it is guaranteed to be in the diff --git a/src/sweeper-thread.cc b/src/sweeper-thread.cc index ea2553d..9ce5ec4 100644 --- a/src/sweeper-thread.cc +++ b/src/sweeper-thread.cc @@ -67,7 +67,7 @@ void SweeperThread::WaitForSweeperThread() { bool SweeperThread::SweepingCompleted() { - bool value = end_sweeping_semaphore_.WaitFor(TimeDelta::FromSeconds(0)); + bool value = end_sweeping_semaphore_.WaitFor(base::TimeDelta::FromSeconds(0)); if (value) { end_sweeping_semaphore_.Signal(); } diff --git a/src/sweeper-thread.h b/src/sweeper-thread.h index 02cace6..692dfea 100644 --- a/src/sweeper-thread.h +++ b/src/sweeper-thread.h @@ -6,8 +6,8 @@ #define V8_SWEEPER_THREAD_H_ #include "src/base/atomicops.h" +#include "src/base/platform/platform.h" #include "src/flags.h" -#include "src/platform.h" #include "src/utils.h" #include "src/spaces.h" @@ -17,7 +17,7 @@ namespace v8 { namespace internal { -class SweeperThread : public Thread { +class SweeperThread : public base::Thread { public: explicit SweeperThread(Isolate* isolate); ~SweeperThread() {} @@ -34,9 +34,9 @@ class SweeperThread : public Thread { Isolate* isolate_; Heap* heap_; MarkCompactCollector* collector_; - Semaphore start_sweeping_semaphore_; - Semaphore end_sweeping_semaphore_; - Semaphore stop_semaphore_; + base::Semaphore start_sweeping_semaphore_; + base::Semaphore end_sweeping_semaphore_; + base::Semaphore stop_semaphore_; volatile base::AtomicWord stop_thread_; }; diff --git a/src/token.h b/src/token.h index 12ae424..6156036 100644 --- a/src/token.h +++ b/src/token.h @@ -5,7 +5,7 @@ #ifndef V8_TOKEN_H_ #define V8_TOKEN_H_ -#include "src/checks.h" +#include "src/base/logging.h" namespace v8 { namespace internal { diff --git a/src/transitions.h b/src/transitions.h index ec99c8b..bbbe944 100644 --- a/src/transitions.h +++ b/src/transitions.h @@ -5,11 +5,11 @@ #ifndef V8_TRANSITIONS_H_ #define V8_TRANSITIONS_H_ +#include "src/checks.h" #include "src/elements-kind.h" #include "src/heap.h" #include "src/isolate.h" #include "src/objects.h" -#include "src/v8checks.h" namespace v8 { namespace internal { diff --git a/src/unicode-inl.h b/src/unicode-inl.h index 6ef7f98..fbb175a 100644 --- a/src/unicode-inl.h +++ b/src/unicode-inl.h @@ -6,7 +6,7 @@ #define V8_UNICODE_INL_H_ #include "src/unicode.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/utils.h" namespace unibrow { diff --git a/src/utils.cc b/src/utils.cc index df1f280..aca9a99 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -7,8 +7,8 @@ #include "src/v8.h" -#include "src/checks.h" -#include "src/platform.h" +#include "src/base/logging.h" +#include "src/base/platform/platform.h" #include "src/utils.h" namespace v8 { @@ -80,7 +80,7 @@ char* SimpleStringBuilder::Finalize() { void PrintF(const char* format, ...) { va_list arguments; va_start(arguments, format); - OS::VPrint(format, arguments); + base::OS::VPrint(format, arguments); va_end(arguments); } @@ -88,16 +88,16 @@ void PrintF(const char* format, ...) { void PrintF(FILE* out, const char* format, ...) { va_list arguments; va_start(arguments, format); - OS::VFPrint(out, format, arguments); + base::OS::VFPrint(out, format, arguments); va_end(arguments); } void PrintPID(const char* format, ...) { - OS::Print("[%d] ", OS::GetCurrentProcessId()); + base::OS::Print("[%d] ", base::OS::GetCurrentProcessId()); va_list arguments; va_start(arguments, format); - OS::VPrint(format, arguments); + base::OS::VPrint(format, arguments); va_end(arguments); } @@ -112,12 +112,12 @@ int SNPrintF(Vector str, const char* format, ...) { int VSNPrintF(Vector str, const char* format, va_list args) { - return OS::VSNPrintF(str.start(), str.length(), format, args); + return base::OS::VSNPrintF(str.start(), str.length(), format, args); } void StrNCpy(Vector dest, const char* src, size_t n) { - OS::StrNCpy(dest.start(), dest.length(), src, n); + base::OS::StrNCpy(dest.start(), dest.length(), src, n); } @@ -185,7 +185,7 @@ char* ReadCharsFromFile(FILE* file, const char* filename) { if (file == NULL || fseek(file, 0, SEEK_END) != 0) { if (verbose) { - OS::PrintError("Cannot read from file %s.\n", filename); + base::OS::PrintError("Cannot read from file %s.\n", filename); } return NULL; } @@ -212,7 +212,7 @@ char* ReadCharsFromFile(const char* filename, int* size, int extra_space, bool verbose) { - FILE* file = OS::FOpen(filename, "rb"); + FILE* file = base::OS::FOpen(filename, "rb"); char* result = ReadCharsFromFile(file, size, extra_space, verbose, filename); if (file != NULL) fclose(file); return result; @@ -274,10 +274,10 @@ int AppendChars(const char* filename, const char* str, int size, bool verbose) { - FILE* f = OS::FOpen(filename, "ab"); + FILE* f = base::OS::FOpen(filename, "ab"); if (f == NULL) { if (verbose) { - OS::PrintError("Cannot open file %s for writing.\n", filename); + base::OS::PrintError("Cannot open file %s for writing.\n", filename); } return 0; } @@ -291,10 +291,10 @@ int WriteChars(const char* filename, const char* str, int size, bool verbose) { - FILE* f = OS::FOpen(filename, "wb"); + FILE* f = base::OS::FOpen(filename, "wb"); if (f == NULL) { if (verbose) { - OS::PrintError("Cannot open file %s for writing.\n", filename); + base::OS::PrintError("Cannot open file %s for writing.\n", filename); } return 0; } diff --git a/src/utils.h b/src/utils.h index da5d0fc..35891f4 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,11 +10,11 @@ #include #include "src/allocation.h" +#include "src/base/logging.h" #include "src/base/macros.h" -#include "src/checks.h" +#include "src/base/platform/platform.h" #include "src/globals.h" #include "src/list.h" -#include "src/platform.h" #include "src/vector.h" namespace v8 { @@ -23,14 +23,6 @@ namespace internal { // ---------------------------------------------------------------------------- // General helper functions -// Returns true iff x is a power of 2. Cannot be used with the maximally -// negative value of the type T (the -1 overflows). -template -inline bool IsPowerOf2(T x) { - return IS_POWER_OF_TWO(x); -} - - // X must be a power of 2. Returns the number of trailing zeros. inline int WhichPowerOf2(uint32_t x) { ASSERT(IsPowerOf2(x)); @@ -90,50 +82,6 @@ inline int ArithmeticShiftRight(int x, int s) { } -// Compute the 0-relative offset of some absolute value x of type T. -// This allows conversion of Addresses and integral types into -// 0-relative int offsets. -template -inline intptr_t OffsetFrom(T x) { - return x - static_cast(0); -} - - -// Compute the absolute value of type T for some 0-relative offset x. -// This allows conversion of 0-relative int offsets into Addresses and -// integral types. -template -inline T AddressFrom(intptr_t x) { - return static_cast(static_cast(0) + x); -} - - -// Return the largest multiple of m which is <= x. -template -inline T RoundDown(T x, intptr_t m) { - ASSERT(IsPowerOf2(m)); - return AddressFrom(OffsetFrom(x) & -m); -} - - -// Return the smallest multiple of m which is >= x. -template -inline T RoundUp(T x, intptr_t m) { - return RoundDown(static_cast(x + m - 1), m); -} - - -// Increment a pointer until it has the specified alignment. -// This works like RoundUp, but it works correctly on pointer types where -// sizeof(*pointer) might not be 1. -template -T AlignUp(T pointer, size_t alignment) { - ASSERT(sizeof(pointer) == sizeof(uintptr_t)); - uintptr_t pointer_raw = reinterpret_cast(pointer); - return reinterpret_cast(RoundUp(pointer_raw, alignment)); -} - - template int Compare(const T& a, const T& b) { if (a == b) @@ -161,35 +109,6 @@ int HandleObjectPointerCompare(const Handle* a, const Handle* b) { } -// Returns the smallest power of two which is >= x. If you pass in a -// number that is already a power of two, it is returned as is. -// Implementation is from "Hacker's Delight" by Henry S. Warren, Jr., -// figure 3-3, page 48, where the function is called clp2. -inline uint32_t RoundUpToPowerOf2(uint32_t x) { - ASSERT(x <= 0x80000000u); - x = x - 1; - x = x | (x >> 1); - x = x | (x >> 2); - x = x | (x >> 4); - x = x | (x >> 8); - x = x | (x >> 16); - return x + 1; -} - - -inline uint32_t RoundDownToPowerOf2(uint32_t x) { - uint32_t rounded_up = RoundUpToPowerOf2(x); - if (rounded_up > x) return rounded_up >> 1; - return rounded_up; -} - - -template -inline bool IsAligned(T value, U alignment) { - return (value & (alignment - 1)) == 0; -} - - // Returns true if (addr + offset) is aligned. inline bool IsAddressAligned(Address addr, intptr_t alignment, diff --git a/src/utils/DEPS b/src/utils/DEPS deleted file mode 100644 index 3da1ce1..0000000 --- a/src/utils/DEPS +++ /dev/null @@ -1,5 +0,0 @@ -include_rules = [ - "-src", - "+src/base", - "+src/platform", -] diff --git a/src/v8.cc b/src/v8.cc index f836270..394629c 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -6,6 +6,7 @@ #include "src/assembler.h" #include "src/base/once.h" +#include "src/base/platform/platform.h" #include "src/bootstrapper.h" #include "src/debug.h" #include "src/deoptimizer.h" @@ -19,7 +20,6 @@ #endif #include "src/lithium-allocator.h" #include "src/objects.h" -#include "src/platform.h" #include "src/runtime-profiler.h" #include "src/sampler.h" #include "src/serialize.h" @@ -90,7 +90,7 @@ void V8::InitializeOncePerProcessImpl() { FLAG_max_semi_space_size = 1; } - OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); + base::OS::Initialize(FLAG_random_seed, FLAG_hard_abort, FLAG_gc_fake_mmap); #ifdef V8_USE_DEFAULT_PLATFORM platform_ = new DefaultPlatform; diff --git a/src/v8.h b/src/v8.h index e90a42c..b0db7ca 100644 --- a/src/v8.h +++ b/src/v8.h @@ -28,7 +28,7 @@ // Basic includes #include "include/v8.h" #include "include/v8-platform.h" -#include "src/v8checks.h" // NOLINT +#include "src/checks.h" // NOLINT #include "src/allocation.h" // NOLINT #include "src/assert-scope.h" // NOLINT #include "src/utils.h" // NOLINT diff --git a/src/v8checks.h b/src/v8checks.h deleted file mode 100644 index 3d63cae..0000000 --- a/src/v8checks.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2006-2008 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8CHECKS_H_ -#define V8_V8CHECKS_H_ - -#include "src/checks.h" - -namespace v8 { - class Value; - template class Handle; - -namespace internal { - intptr_t HeapObjectTagMask(); - -} } // namespace v8::internal - - -void CheckNonEqualsHelper(const char* file, - int line, - const char* unexpected_source, - v8::Handle unexpected, - const char* value_source, - v8::Handle value); - -void CheckEqualsHelper(const char* file, - int line, - const char* expected_source, - v8::Handle expected, - const char* value_source, - v8::Handle value); - -#define ASSERT_TAG_ALIGNED(address) \ - ASSERT((reinterpret_cast(address) & HeapObjectTagMask()) == 0) - -#define ASSERT_SIZE_TAG_ALIGNED(size) ASSERT((size & HeapObjectTagMask()) == 0) - -#endif // V8_V8CHECKS_H_ diff --git a/src/v8threads.h b/src/v8threads.h index ca722ad..c3ba517 100644 --- a/src/v8threads.h +++ b/src/v8threads.h @@ -96,7 +96,7 @@ class ThreadManager { void EagerlyArchiveThread(); - Mutex mutex_; + base::Mutex mutex_; ThreadId mutex_owner_; ThreadId lazily_archived_thread_; ThreadState* lazily_archived_thread_state_; diff --git a/src/x64/assembler-x64-inl.h b/src/x64/assembler-x64-inl.h index f1731af..0006481 100644 --- a/src/x64/assembler-x64-inl.h +++ b/src/x64/assembler-x64-inl.h @@ -7,7 +7,7 @@ #include "src/x64/assembler-x64.h" -#include "src/cpu.h" +#include "src/base/cpu.h" #include "src/debug.h" #include "src/v8memory.h" @@ -196,7 +196,7 @@ void Assembler::set_target_address_at(Address pc, ICacheFlushMode icache_flush_mode) { Memory::int32_at(pc) = static_cast(target - pc - 4); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc, sizeof(int32_t)); + CpuFeatures::FlushICache(pc, sizeof(int32_t)); } } @@ -224,15 +224,15 @@ void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { if (IsInternalReference(rmode_)) { // absolute code pointer inside code object moves with the code object. Memory::Address_at(pc_) += static_cast(delta); - if (flush_icache) CPU::FlushICache(pc_, sizeof(Address)); + if (flush_icache) CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (IsCodeTarget(rmode_) || IsRuntimeEntry(rmode_)) { Memory::int32_at(pc_) -= static_cast(delta); - if (flush_icache) CPU::FlushICache(pc_, sizeof(int32_t)); + if (flush_icache) CpuFeatures::FlushICache(pc_, sizeof(int32_t)); } else if (rmode_ == CODE_AGE_SEQUENCE) { if (*pc_ == kCallOpcode) { int32_t* p = reinterpret_cast(pc_ + 1); *p -= static_cast(delta); // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } } } @@ -310,7 +310,7 @@ void RelocInfo::set_target_object(Object* target, ASSERT(!target->IsConsString()); Memory::Object_at(pc_) = target; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && @@ -357,7 +357,7 @@ void RelocInfo::set_target_cell(Cell* cell, Address address = cell->address() + Cell::kValueOffset; Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { @@ -435,8 +435,8 @@ void RelocInfo::set_call_address(Address target) { (IsDebugBreakSlot(rmode()) && IsPatchedDebugBreakSlotSequence())); Memory::Address_at(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset) = target; - CPU::FlushICache(pc_ + Assembler::kRealPatchReturnSequenceAddressOffset, - sizeof(Address)); + CpuFeatures::FlushICache( + pc_ + Assembler::kRealPatchReturnSequenceAddressOffset, sizeof(Address)); if (host() != NULL) { Object* target_code = Code::GetCodeFromTargetAddress(target); host()->GetHeap()->incremental_marking()->RecordWriteIntoCode( @@ -467,14 +467,14 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { visitor->VisitCodeTarget(this); } else if (mode == RelocInfo::CELL) { visitor->VisitCell(this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { visitor->VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { visitor->VisitCodeAgeSequence(this); } else if (((RelocInfo::IsJSReturn(mode) && @@ -494,14 +494,14 @@ void RelocInfo::Visit(Heap* heap) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { StaticVisitor::VisitEmbeddedPointer(heap, this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { StaticVisitor::VisitCodeTarget(heap, this); } else if (mode == RelocInfo::CELL) { StaticVisitor::VisitCell(heap, this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { StaticVisitor::VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { StaticVisitor::VisitCodeAgeSequence(heap, this); } else if (heap->isolate()->debug()->has_break_points() && diff --git a/src/x64/assembler-x64.cc b/src/x64/assembler-x64.cc index 59b027f..6d3750e 100644 --- a/src/x64/assembler-x64.cc +++ b/src/x64/assembler-x64.cc @@ -16,7 +16,7 @@ namespace internal { // Implementation of CpuFeatures void CpuFeatures::ProbeImpl(bool cross_compile) { - CPU cpu; + base::CPU cpu; CHECK(cpu.has_sse2()); // SSE2 support is mandatory. CHECK(cpu.has_cmov()); // CMOV support is mandatory. @@ -74,7 +74,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count); + CpuFeatures::FlushICache(pc_, instruction_count); } diff --git a/src/x64/code-stubs-x64.h b/src/x64/code-stubs-x64.h index 7f9420c..0c35436 100644 --- a/src/x64/code-stubs-x64.h +++ b/src/x64/code-stubs-x64.h @@ -248,7 +248,7 @@ class RecordWriteStub: public PlatformCodeStub { break; } ASSERT(GetMode(stub) == mode); - CPU::FlushICache(stub->instruction_start(), 7); + CpuFeatures::FlushICache(stub->instruction_start(), 7); } private: diff --git a/src/x64/codegen-x64.cc b/src/x64/codegen-x64.cc index 0f939d9..d30ca49 100644 --- a/src/x64/codegen-x64.cc +++ b/src/x64/codegen-x64.cc @@ -35,7 +35,8 @@ void StubRuntimeCallHelper::AfterCall(MacroAssembler* masm) const { UnaryMathFunction CreateExpFunction() { if (!FLAG_fast_math) return &std::exp; size_t actual_size; - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::exp; ExternalReference::InitializeMathExpData(); @@ -57,8 +58,8 @@ UnaryMathFunction CreateExpFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -66,9 +67,8 @@ UnaryMathFunction CreateExpFunction() { UnaryMathFunction CreateSqrtFunction() { size_t actual_size; // Allocate buffer in executable space. - byte* buffer = static_cast(OS::Allocate(1 * KB, - &actual_size, - true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return &std::sqrt; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); @@ -81,8 +81,8 @@ UnaryMathFunction CreateSqrtFunction() { masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); return FUNCTION_CAST(buffer); } @@ -92,9 +92,8 @@ typedef double (*ModuloFunction)(double, double); // Define custom fmod implementation. ModuloFunction CreateModuloFunction() { size_t actual_size; - byte* buffer = static_cast(OS::Allocate(Assembler::kMinimalBufferSize, - &actual_size, - true)); + byte* buffer = static_cast( + base::OS::Allocate(Assembler::kMinimalBufferSize, &actual_size, true)); CHECK(buffer); Assembler masm(NULL, buffer, static_cast(actual_size)); // Generated code is put into a fixed, unmovable, buffer, and not into @@ -170,7 +169,7 @@ ModuloFunction CreateModuloFunction() { CodeDesc desc; masm.GetCode(&desc); - OS::ProtectCode(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); // Call the function from C++ through this pointer. return FUNCTION_CAST(buffer); } @@ -665,7 +664,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CPU::FlushICache(sequence, young_length); + CpuFeatures::FlushICache(sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length); diff --git a/src/x64/cpu-x64.cc b/src/x64/cpu-x64.cc index ca2b89b..59a187f 100644 --- a/src/x64/cpu-x64.cc +++ b/src/x64/cpu-x64.cc @@ -12,13 +12,13 @@ #if V8_TARGET_ARCH_X64 -#include "src/cpu.h" +#include "src/assembler.h" #include "src/macro-assembler.h" namespace v8 { namespace internal { -void CPU::FlushICache(void* start, size_t size) { +void CpuFeatures::FlushICache(void* start, size_t size) { // No need to flush the instruction cache on Intel. On Intel instruction // cache flushing is only necessary when multiple cores running the same // code simultaneously. V8 (and JavaScript) is single threaded and when code diff --git a/src/x64/lithium-codegen-x64.h b/src/x64/lithium-codegen-x64.h index 5621a3d..3d2b7b1 100644 --- a/src/x64/lithium-codegen-x64.h +++ b/src/x64/lithium-codegen-x64.h @@ -7,7 +7,7 @@ #include "src/x64/lithium-x64.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/deoptimizer.h" #include "src/lithium-codegen.h" #include "src/safepoint-table.h" diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 73c59df..67ad2a9 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -542,7 +542,7 @@ void MacroAssembler::Check(Condition cc, BailoutReason reason) { void MacroAssembler::CheckStackAlignment() { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); int frame_alignment_mask = frame_alignment - 1; if (frame_alignment > kPointerSize) { ASSERT(IsPowerOf2(frame_alignment)); @@ -4097,7 +4097,7 @@ void MacroAssembler::EnterExitFrameEpilogue(int arg_stack_space, } // Get the required frame alignment for the OS. - const int kFrameAlignment = OS::ActivationFrameAlignment(); + const int kFrameAlignment = base::OS::ActivationFrameAlignment(); if (kFrameAlignment > 0) { ASSERT(IsPowerOf2(kFrameAlignment)); ASSERT(is_int8(kFrameAlignment)); @@ -4977,7 +4977,7 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string, void MacroAssembler::PrepareCallCFunction(int num_arguments) { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); ASSERT(frame_alignment != 0); ASSERT(num_arguments >= 0); @@ -5007,7 +5007,7 @@ void MacroAssembler::CallCFunction(Register function, int num_arguments) { } call(function); - ASSERT(OS::ActivationFrameAlignment() != 0); + ASSERT(base::OS::ActivationFrameAlignment() != 0); ASSERT(num_arguments >= 0); int argument_slots_on_stack = ArgumentStackSlotsForCFunctionCall(num_arguments); @@ -5039,7 +5039,7 @@ CodePatcher::CodePatcher(byte* address, int size) CodePatcher::~CodePatcher() { // Indicate that code has changed. - CPU::FlushICache(address_, size_); + CpuFeatures::FlushICache(address_, size_); // Check that the code was patched as expected. ASSERT(masm_.pc_ == address_ + size_); diff --git a/src/x87/assembler-x87-inl.h b/src/x87/assembler-x87-inl.h index 4a5583c..e168292 100644 --- a/src/x87/assembler-x87-inl.h +++ b/src/x87/assembler-x87-inl.h @@ -39,7 +39,7 @@ #include "src/x87/assembler-x87.h" -#include "src/cpu.h" +#include "src/assembler.h" #include "src/debug.h" namespace v8 { @@ -58,30 +58,30 @@ void RelocInfo::apply(intptr_t delta, ICacheFlushMode icache_flush_mode) { if (IsRuntimeEntry(rmode_) || IsCodeTarget(rmode_)) { int32_t* p = reinterpret_cast(pc_); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (rmode_ == CODE_AGE_SEQUENCE) { if (*pc_ == kCallOpcode) { int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } } else if (rmode_ == JS_RETURN && IsPatchedReturnSequence()) { // Special handling of js_return when a break point is set (call // instruction has been inserted). int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (rmode_ == DEBUG_BREAK_SLOT && IsPatchedDebugBreakSlotSequence()) { // Special handling of a debug break slot when a break point is set (call // instruction has been inserted). int32_t* p = reinterpret_cast(pc_ + 1); *p -= delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } else if (IsInternalReference(rmode_)) { // absolute code pointer inside code object moves with the code object. int32_t* p = reinterpret_cast(pc_); *p += delta; // Relocate entry. - if (flush_icache) CPU::FlushICache(p, sizeof(uint32_t)); + if (flush_icache) CpuFeatures::FlushICache(p, sizeof(uint32_t)); } } @@ -145,7 +145,7 @@ void RelocInfo::set_target_object(Object* target, ASSERT(!target->IsConsString()); Memory::Object_at(pc_) = target; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL && @@ -198,7 +198,7 @@ void RelocInfo::set_target_cell(Cell* cell, Address address = cell->address() + Cell::kValueOffset; Memory::Address_at(pc_) = address; if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } if (write_barrier_mode == UPDATE_WRITE_BARRIER && host() != NULL) { // TODO(1550) We are passing NULL as a slot because cell can never be on @@ -295,14 +295,14 @@ void RelocInfo::Visit(Isolate* isolate, ObjectVisitor* visitor) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { visitor->VisitEmbeddedPointer(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { visitor->VisitCodeTarget(this); } else if (mode == RelocInfo::CELL) { visitor->VisitCell(this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { visitor->VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { visitor->VisitCodeAgeSequence(this); } else if (((RelocInfo::IsJSReturn(mode) && @@ -322,14 +322,14 @@ void RelocInfo::Visit(Heap* heap) { RelocInfo::Mode mode = rmode(); if (mode == RelocInfo::EMBEDDED_OBJECT) { StaticVisitor::VisitEmbeddedPointer(heap, this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeTarget(mode)) { StaticVisitor::VisitCodeTarget(heap, this); } else if (mode == RelocInfo::CELL) { StaticVisitor::VisitCell(heap, this); } else if (mode == RelocInfo::EXTERNAL_REFERENCE) { StaticVisitor::VisitExternalReference(this); - CPU::FlushICache(pc_, sizeof(Address)); + CpuFeatures::FlushICache(pc_, sizeof(Address)); } else if (RelocInfo::IsCodeAgeSequence(mode)) { StaticVisitor::VisitCodeAgeSequence(heap, this); } else if (heap->isolate()->debug()->has_break_points() && @@ -474,7 +474,7 @@ void Assembler::set_target_address_at(Address pc, int32_t* p = reinterpret_cast(pc); *p = target - (pc + sizeof(int32_t)); if (icache_flush_mode != SKIP_ICACHE_FLUSH) { - CPU::FlushICache(p, sizeof(int32_t)); + CpuFeatures::FlushICache(p, sizeof(int32_t)); } } diff --git a/src/x87/assembler-x87.cc b/src/x87/assembler-x87.cc index f2082c2..eeabcf9 100644 --- a/src/x87/assembler-x87.cc +++ b/src/x87/assembler-x87.cc @@ -49,7 +49,7 @@ namespace internal { // Implementation of CpuFeatures void CpuFeatures::ProbeImpl(bool cross_compile) { - CPU cpu; + base::CPU cpu; // Only use statically determined features for cross compile (snapshot). if (cross_compile) return; @@ -107,7 +107,7 @@ void RelocInfo::PatchCode(byte* instructions, int instruction_count) { } // Indicate that code has changed. - CPU::FlushICache(pc_, instruction_count); + CpuFeatures::FlushICache(pc_, instruction_count); } diff --git a/src/x87/code-stubs-x87.h b/src/x87/code-stubs-x87.h index 76d508a..6dbb44f 100644 --- a/src/x87/code-stubs-x87.h +++ b/src/x87/code-stubs-x87.h @@ -244,7 +244,7 @@ class RecordWriteStub: public PlatformCodeStub { break; } ASSERT(GetMode(stub) == mode); - CPU::FlushICache(stub->instruction_start(), 7); + CpuFeatures::FlushICache(stub->instruction_start(), 7); } private: diff --git a/src/x87/codegen-x87.cc b/src/x87/codegen-x87.cc index 5091e88..334490a 100644 --- a/src/x87/codegen-x87.cc +++ b/src/x87/codegen-x87.cc @@ -79,7 +79,8 @@ class LabelConverter { MemMoveFunction CreateMemMoveFunction() { size_t actual_size; // Allocate buffer in executable space. - byte* buffer = static_cast(OS::Allocate(1 * KB, &actual_size, true)); + byte* buffer = + static_cast(base::OS::Allocate(1 * KB, &actual_size, true)); if (buffer == NULL) return NULL; MacroAssembler masm(NULL, buffer, static_cast(actual_size)); LabelConverter conv(buffer); @@ -181,8 +182,8 @@ MemMoveFunction CreateMemMoveFunction() { CodeDesc desc; masm.GetCode(&desc); ASSERT(!RelocInfo::RequiresRelocation(desc)); - CPU::FlushICache(buffer, actual_size); - OS::ProtectCode(buffer, actual_size); + CpuFeatures::FlushICache(buffer, actual_size); + base::OS::ProtectCode(buffer, actual_size); // TODO(jkummerow): It would be nice to register this code creation event // with the PROFILE / GDBJIT system. return FUNCTION_CAST(buffer); @@ -618,7 +619,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); if (age == kNoAgeCodeAge) { isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); - CPU::FlushICache(sequence, young_length); + CpuFeatures::FlushICache(sequence, young_length); } else { Code* stub = GetCodeAgeStub(isolate, age, parity); CodePatcher patcher(sequence, young_length); diff --git a/src/x87/cpu-x87.cc b/src/x87/cpu-x87.cc index 469f58e..03816df 100644 --- a/src/x87/cpu-x87.cc +++ b/src/x87/cpu-x87.cc @@ -12,13 +12,13 @@ #if V8_TARGET_ARCH_X87 -#include "src/cpu.h" +#include "src/assembler.h" #include "src/macro-assembler.h" namespace v8 { namespace internal { -void CPU::FlushICache(void* start, size_t size) { +void CpuFeatures::FlushICache(void* start, size_t size) { // No need to flush the instruction cache on Intel. On Intel instruction // cache flushing is only necessary when multiple cores running the same // code simultaneously. V8 (and JavaScript) is single threaded and when code diff --git a/src/x87/lithium-codegen-x87.h b/src/x87/lithium-codegen-x87.h index 74cc6f3..15cc048 100644 --- a/src/x87/lithium-codegen-x87.h +++ b/src/x87/lithium-codegen-x87.h @@ -7,7 +7,7 @@ #include "src/x87/lithium-x87.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/deoptimizer.h" #include "src/lithium-codegen.h" #include "src/safepoint-table.h" diff --git a/src/x87/macro-assembler-x87.cc b/src/x87/macro-assembler-x87.cc index 585f9c0..c549668 100644 --- a/src/x87/macro-assembler-x87.cc +++ b/src/x87/macro-assembler-x87.cc @@ -894,7 +894,7 @@ void MacroAssembler::EnterExitFrameEpilogue(int argc) { sub(esp, Immediate(argc * kPointerSize)); // Get the required frame alignment for the OS. - const int kFrameAlignment = OS::ActivationFrameAlignment(); + const int kFrameAlignment = base::OS::ActivationFrameAlignment(); if (kFrameAlignment > 0) { ASSERT(IsPowerOf2(kFrameAlignment)); and_(esp, -kFrameAlignment); @@ -2659,7 +2659,7 @@ void MacroAssembler::Check(Condition cc, BailoutReason reason) { void MacroAssembler::CheckStackAlignment() { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); int frame_alignment_mask = frame_alignment - 1; if (frame_alignment > kPointerSize) { ASSERT(IsPowerOf2(frame_alignment)); @@ -2886,7 +2886,7 @@ void MacroAssembler::EmitSeqStringSetCharCheck(Register string, void MacroAssembler::PrepareCallCFunction(int num_arguments, Register scratch) { - int frame_alignment = OS::ActivationFrameAlignment(); + int frame_alignment = base::OS::ActivationFrameAlignment(); if (frame_alignment != 0) { // Make stack end at alignment and make room for num_arguments words // and the original value of esp. @@ -2918,7 +2918,7 @@ void MacroAssembler::CallCFunction(Register function, } call(function); - if (OS::ActivationFrameAlignment() != 0) { + if (base::OS::ActivationFrameAlignment() != 0) { mov(esp, Operand(esp, num_arguments * kPointerSize)); } else { add(esp, Immediate(num_arguments * kPointerSize)); @@ -2950,7 +2950,7 @@ CodePatcher::CodePatcher(byte* address, int size) CodePatcher::~CodePatcher() { // Indicate that code has changed. - CPU::FlushICache(address_, size_); + CpuFeatures::FlushICache(address_, size_); // Check that the code was patched as expected. ASSERT(masm_.pc_ == address_ + size_); diff --git a/src/zone.h b/src/zone.h index 643beb7..a689f12 100644 --- a/src/zone.h +++ b/src/zone.h @@ -6,7 +6,7 @@ #define V8_ZONE_H_ #include "src/allocation.h" -#include "src/checks.h" +#include "src/base/logging.h" #include "src/globals.h" #include "src/hashmap.h" #include "src/list.h" diff --git a/test/cctest/cctest.h b/test/cctest/cctest.h index a357be4..1fadfb7 100644 --- a/test/cctest/cctest.h +++ b/test/cctest/cctest.h @@ -177,7 +177,7 @@ class CcTest { // thread fuzzing test. In the thread fuzzing test it will // pseudorandomly select a successor thread and switch execution // to that thread, suspending the current test. -class ApiTestFuzzer: public v8::internal::Thread { +class ApiTestFuzzer: public v8::base::Thread { public: void CallTest(); @@ -212,11 +212,11 @@ class ApiTestFuzzer: public v8::internal::Thread { static int active_tests_; static bool NextThread(); int test_number_; - v8::internal::Semaphore gate_; + v8::base::Semaphore gate_; bool active_; void ContextSwitch(); static int GetNextTestNumber(); - static v8::internal::Semaphore all_tests_done_; + static v8::base::Semaphore all_tests_done_; }; diff --git a/test/cctest/profiler-extension.cc b/test/cctest/profiler-extension.cc index 5779bf4..263fc4f 100644 --- a/test/cctest/profiler-extension.cc +++ b/test/cctest/profiler-extension.cc @@ -27,8 +27,8 @@ // // Tests of profiles generator and utilities. +#include "src/base/logging.h" #include "test/cctest/profiler-extension.h" -#include "src/checks.h" namespace v8 { namespace internal { diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 7d251f2..5f78134 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -39,13 +39,13 @@ #include "include/v8-util.h" #include "src/api.h" #include "src/arguments.h" +#include "src/base/platform/platform.h" #include "src/compilation-cache.h" #include "src/cpu-profiler.h" #include "src/execution.h" #include "src/isolate.h" #include "src/objects.h" #include "src/parser.h" -#include "src/platform.h" #include "src/snapshot.h" #include "src/unicode-inl.h" #include "src/utils.h" @@ -5399,7 +5399,7 @@ THREADED_TEST(Equality) { CHECK(v8_num(1)->StrictEquals(v8_num(1))); CHECK(!v8_num(1)->StrictEquals(v8_num(2))); CHECK(v8_num(0.0)->StrictEquals(v8_num(-0.0))); - Local not_a_number = v8_num(i::OS::nan_value()); + Local not_a_number = v8_num(v8::base::OS::nan_value()); CHECK(!not_a_number->StrictEquals(not_a_number)); CHECK(v8::False(isolate)->StrictEquals(v8::False(isolate))); CHECK(!v8::False(isolate)->StrictEquals(v8::Undefined(isolate))); @@ -13096,7 +13096,7 @@ THREADED_TEST(ObjectGetConstructorName) { bool ApiTestFuzzer::fuzzing_ = false; -i::Semaphore ApiTestFuzzer::all_tests_done_(0); +v8::base::Semaphore ApiTestFuzzer::all_tests_done_(0); int ApiTestFuzzer::active_tests_; int ApiTestFuzzer::tests_being_run_; int ApiTestFuzzer::current_; @@ -15158,7 +15158,7 @@ struct RegExpInterruptionData { } regexp_interruption_data; -class RegExpInterruptionThread : public i::Thread { +class RegExpInterruptionThread : public v8::base::Thread { public: explicit RegExpInterruptionThread(v8::Isolate* isolate) : Thread("TimeoutThread"), isolate_(isolate) {} @@ -15167,10 +15167,10 @@ class RegExpInterruptionThread : public i::Thread { for (regexp_interruption_data.loop_count = 0; regexp_interruption_data.loop_count < 7; regexp_interruption_data.loop_count++) { - i::OS::Sleep(50); // Wait a bit before requesting GC. + v8::base::OS::Sleep(50); // Wait a bit before requesting GC. reinterpret_cast(isolate_)->stack_guard()->RequestGC(); } - i::OS::Sleep(50); // Wait a bit before terminating. + v8::base::OS::Sleep(50); // Wait a bit before terminating. v8::V8::TerminateExecution(isolate_); } @@ -16252,7 +16252,7 @@ static void ObjectWithExternalArrayTestHelper( CHECK_EQ(0, result->Int32Value()); if (array_type == v8::kExternalFloat64Array || array_type == v8::kExternalFloat32Array) { - CHECK_EQ(static_cast(i::OS::nan_value()), + CHECK_EQ(static_cast(v8::base::OS::nan_value()), static_cast( i::Object::GetElement( isolate, jsobj, 7).ToHandleChecked()->Number())); @@ -18031,7 +18031,7 @@ static uint64_t DoubleToBits(double value) { static double DoubleToDateTime(double input) { double date_limit = 864e13; if (std::isnan(input) || input < -date_limit || input > date_limit) { - return i::OS::nan_value(); + return v8::base::OS::nan_value(); } return (input < 0) ? -(std::floor(-input)) : std::floor(input); } @@ -19362,7 +19362,7 @@ static int CalcFibonacci(v8::Isolate* isolate, int limit) { return static_cast(value->NumberValue()); } -class IsolateThread : public v8::internal::Thread { +class IsolateThread : public v8::base::Thread { public: IsolateThread(v8::Isolate* isolate, int fib_limit) : Thread("IsolateThread"), @@ -19436,7 +19436,7 @@ TEST(IsolateDifferentContexts) { isolate->Dispose(); } -class InitDefaultIsolateThread : public v8::internal::Thread { +class InitDefaultIsolateThread : public v8::base::Thread { public: enum TestCase { SetResourceConstraints, @@ -20546,13 +20546,13 @@ uint8_t callback_fired = 0; void CallCompletedCallback1() { - i::OS::Print("Firing callback 1.\n"); + v8::base::OS::Print("Firing callback 1.\n"); callback_fired ^= 1; // Toggle first bit. } void CallCompletedCallback2() { - i::OS::Print("Firing callback 2.\n"); + v8::base::OS::Print("Firing callback 2.\n"); callback_fired ^= 2; // Toggle second bit. } @@ -20561,15 +20561,15 @@ void RecursiveCall(const v8::FunctionCallbackInfo& args) { int32_t level = args[0]->Int32Value(); if (level < 3) { level++; - i::OS::Print("Entering recursion level %d.\n", level); + v8::base::OS::Print("Entering recursion level %d.\n", level); char script[64]; i::Vector script_vector(script, sizeof(script)); i::SNPrintF(script_vector, "recursion(%d)", level); CompileRun(script_vector.start()); - i::OS::Print("Leaving recursion level %d.\n", level); + v8::base::OS::Print("Leaving recursion level %d.\n", level); CHECK_EQ(0, callback_fired); } else { - i::OS::Print("Recursion ends.\n"); + v8::base::OS::Print("Recursion ends.\n"); CHECK_EQ(0, callback_fired); } } @@ -20586,19 +20586,19 @@ TEST(CallCompletedCallback) { env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1); env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback1); env->GetIsolate()->AddCallCompletedCallback(CallCompletedCallback2); - i::OS::Print("--- Script (1) ---\n"); + v8::base::OS::Print("--- Script (1) ---\n"); Local