From 6cac1382f43eb6be77eff43d581b9fd4b0e2b0bc Mon Sep 17 00:00:00 2001 From: Jakob Kummerow Date: Thu, 14 Feb 2019 13:10:30 -0800 Subject: [PATCH] [cleanup] #include heap-inl.h less often This takes heap-inl.h out of the "Giant Include Cluster". Naturally, that means adding a bunch of explicit includes in a bunch of places that relied on transitively including them before. As of this patch, no header file outside src/heap/ includes heap-inl.h. Bug: v8:8562,v8:8499 Change-Id: I65fa763f90e66afc30d105b9277792721f05a6d4 Reviewed-on: https://chromium-review.googlesource.com/c/1459659 Commit-Queue: Jakob Kummerow Reviewed-by: Jakob Gruber Reviewed-by: Michael Lippautz Reviewed-by: Michael Starzinger Reviewed-by: Toon Verwaest Reviewed-by: Sigurd Schneider Cr-Commit-Position: refs/heads/master@{#59617} --- BUILD.gn | 1 + src/api.cc | 15 +-- src/arguments-inl.h | 2 +- src/arm/macro-assembler-arm.cc | 1 + src/arm64/macro-assembler-arm64.cc | 1 + src/assembler.cc | 1 + src/ast/ast.cc | 1 + src/bootstrapper.cc | 2 +- src/builtins/arm/builtins-arm.cc | 2 + src/builtins/arm64/builtins-arm64.cc | 2 + src/builtins/builtins-array-gen.cc | 1 + src/builtins/builtins-arraybuffer.cc | 1 + src/builtins/builtins-boolean.cc | 1 + src/builtins/builtins-callsite.cc | 1 + src/builtins/builtins-collections-gen.cc | 1 + src/builtins/builtins-microtask-queue-gen.cc | 1 + src/builtins/builtins-object.cc | 1 + src/builtins/builtins-promise.cc | 1 + src/builtins/builtins-string-gen.cc | 1 + src/builtins/builtins-string.cc | 1 + src/builtins/builtins-symbol.cc | 1 + src/builtins/builtins-trace.cc | 1 + src/builtins/ia32/builtins-ia32.cc | 2 + src/builtins/mips/builtins-mips.cc | 2 + src/builtins/mips64/builtins-mips64.cc | 2 + src/builtins/ppc/builtins-ppc.cc | 2 + src/builtins/s390/builtins-s390.cc | 2 + src/builtins/setup-builtins-internal.cc | 2 +- src/builtins/x64/builtins-x64.cc | 2 + src/code-factory.cc | 1 + src/code-reference.cc | 1 + src/code-stub-assembler.cc | 1 + .../compiler-dispatcher.cc | 1 + src/compiler.cc | 1 + src/compiler/compilation-dependencies.cc | 1 + src/compiler/js-heap-broker.cc | 5 +- src/contexts-inl.h | 1 + src/debug/debug.cc | 1 + src/deoptimizer.cc | 3 +- src/elements.cc | 3 +- src/external-reference.cc | 10 +- src/external-reference.h | 2 - src/feedback-vector-inl.h | 5 +- src/frames.cc | 2 +- src/global-handles.cc | 11 ++- src/handles.cc | 7 +- src/hash-seed-inl.h | 44 +++++++++ src/heap/array-buffer-tracker-inl.h | 4 +- src/heap/code-stats.cc | 1 + src/heap/factory-inl.h | 2 + src/heap/factory.cc | 10 +- src/heap/heap-controller.cc | 6 +- src/heap/heap-inl.h | 21 ---- src/heap/heap-write-barrier-inl.h | 96 ++++++++++++++++--- src/heap/heap.cc | 63 ++++++++++++ src/heap/heap.h | 6 +- src/heap/mark-compact-inl.h | 5 +- src/heap/setup-heap-internal.cc | 2 +- src/heap/spaces-inl.h | 4 +- src/heap/spaces.cc | 8 ++ src/heap/spaces.h | 18 ++-- src/ia32/macro-assembler-ia32.cc | 1 + src/ic/stub-cache.cc | 2 +- src/isolate-inl.h | 43 ++++----- src/isolate.cc | 5 +- src/isolate.h | 11 +-- src/json-parser.cc | 5 +- src/log.cc | 3 +- src/mips/macro-assembler-mips.cc | 1 + src/mips64/macro-assembler-mips64.cc | 1 + src/objects-debug.cc | 8 +- src/objects-inl.h | 27 ++---- src/objects-printer.cc | 9 +- src/objects.cc | 15 ++- src/objects.h | 4 +- src/objects/allocation-site-inl.h | 2 +- src/objects/api-callbacks-inl.h | 3 +- src/objects/bigint.cc | 6 ++ src/objects/cell-inl.h | 3 +- src/objects/code-inl.h | 4 +- src/objects/code.cc | 6 +- src/objects/debug-objects-inl.h | 4 +- src/objects/dictionary-inl.h | 5 +- src/objects/embedder-data-array-inl.h | 2 +- src/objects/embedder-data-array.cc | 2 + src/objects/embedder-data-slot-inl.h | 8 +- src/objects/feedback-cell-inl.h | 2 + src/objects/fixed-array-inl.h | 7 +- src/objects/foreign-inl.h | 1 + src/objects/free-space-inl.h | 17 ++-- src/objects/hash-table-inl.h | 2 + src/objects/heap-number-inl.h | 3 +- src/objects/heap-object-inl.h | 7 +- src/objects/heap-object.h | 2 +- src/objects/js-array-buffer-inl.h | 4 +- src/objects/js-collection-inl.h | 3 + src/objects/js-objects-inl.h | 14 +-- src/objects/js-objects.cc | 6 +- src/objects/map-inl.h | 7 +- src/objects/maybe-object-inl.h | 3 +- src/objects/microtask-inl.h | 2 + src/objects/name-inl.h | 5 +- src/objects/object-macros.h | 8 +- src/objects/oddball-inl.h | 5 +- src/objects/ordered-hash-table-inl.h | 1 + src/objects/ordered-hash-table.cc | 1 + src/objects/property-array-inl.h | 1 + src/objects/property-cell-inl.h | 4 +- src/objects/prototype-info-inl.h | 5 +- src/objects/shared-function-info-inl.h | 4 +- src/objects/stack-frame-info-inl.h | 2 + src/objects/string-inl.h | 9 +- src/objects/string.cc | 18 ++-- src/objects/struct-inl.h | 1 + src/objects/templates-inl.h | 2 +- src/parsing/parse-info.cc | 3 +- src/parsing/parser.cc | 1 + src/parsing/parsing.cc | 1 + src/parsing/preparse-data.cc | 1 + src/parsing/preparser.cc | 1 + src/parsing/rewriter.cc | 1 + src/ppc/macro-assembler-ppc.cc | 1 + src/profiler/allocation-tracker.cc | 2 +- src/profiler/heap-snapshot-generator.cc | 18 ++-- src/profiler/sampling-heap-profiler.cc | 6 +- src/profiler/tick-sample.cc | 1 + src/property-descriptor.cc | 1 + src/regexp/jsregexp.cc | 4 +- src/regexp/regexp-parser.cc | 1 + src/roots-inl.h | 42 +++++--- src/roots.cc | 20 ++++ src/roots.h | 7 +- src/runtime/runtime-array.cc | 5 +- src/runtime/runtime-collections.cc | 1 + src/runtime/runtime-debug.cc | 1 + src/runtime/runtime-forin.cc | 1 + src/runtime/runtime-function.cc | 1 + src/runtime/runtime-numbers.cc | 1 + src/runtime/runtime-object.cc | 1 + src/runtime/runtime-operators.cc | 1 + src/runtime/runtime-proxy.cc | 1 + src/runtime/runtime-regexp.cc | 2 +- src/runtime/runtime-scopes.cc | 1 + src/runtime/runtime-strings.cc | 1 + src/runtime/runtime-symbol.cc | 1 + src/runtime/runtime-test.cc | 4 +- src/s390/macro-assembler-s390.cc | 1 + src/snapshot/code-serializer.cc | 1 + src/snapshot/deserializer.cc | 1 + src/snapshot/object-deserializer.cc | 2 + src/snapshot/partial-deserializer.cc | 1 + src/snapshot/read-only-serializer.cc | 5 +- src/snapshot/roots-serializer.cc | 2 +- src/snapshot/serializer.cc | 2 +- src/snapshot/startup-serializer.cc | 3 +- src/string-builder.cc | 6 +- src/wasm/module-compiler.cc | 1 + src/wasm/module-instantiate.cc | 1 + src/wasm/wasm-objects-inl.h | 5 +- src/x64/macro-assembler-x64.cc | 1 + test/cctest/heap/test-alloc.cc | 1 + test/cctest/heap/test-compaction.cc | 1 + test/cctest/heap/test-embedder-tracing.cc | 1 + .../heap/test-external-string-tracker.cc | 1 + test/cctest/heap/test-heap.cc | 4 +- test/cctest/heap/test-weak-references.cc | 1 + test/cctest/interpreter/interpreter-tester.cc | 1 + .../test-interpreter-intrinsics.cc | 1 + test/cctest/interpreter/test-interpreter.cc | 40 ++++---- test/cctest/test-api.cc | 1 + test/cctest/test-code-stub-assembler.cc | 3 +- test/cctest/test-compiler.cc | 2 + test/cctest/test-global-handles.cc | 1 + test/cctest/test-heap-profiler.cc | 1 + test/cctest/test-mementos.cc | 2 +- test/cctest/test-parsing.cc | 64 ++++++------- test/cctest/test-regexp.cc | 1 + test/cctest/test-roots.cc | 5 +- test/cctest/test-serialize.cc | 6 +- test/cctest/test-strings.cc | 1 + test/cctest/test-unboxed-doubles.cc | 1 + test/cctest/test-unwinder.cc | 1 + test/cctest/test-weakmaps.cc | 1 + test/cctest/test-weaksets.cc | 1 + test/cctest/wasm/wasm-run-utils.cc | 1 + test/mkgrokdump/mkgrokdump.cc | 2 +- .../background-compile-task-unittest.cc | 1 + .../compiler-dispatcher-unittest.cc | 1 + test/unittests/heap/heap-unittest.cc | 7 +- .../bytecode-array-builder-unittest.cc | 5 +- .../bytecode-array-iterator-unittest.cc | 3 +- ...bytecode-array-random-iterator-unittest.cc | 15 +-- .../constant-array-builder-unittest.cc | 15 +-- test/unittests/parser/ast-value-unittest.cc | 3 +- 194 files changed, 746 insertions(+), 340 deletions(-) create mode 100644 src/hash-seed-inl.h diff --git a/BUILD.gn b/BUILD.gn index 42f0346e08..9ac9aa8e93 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -2004,6 +2004,7 @@ v8_source_set("v8_base") { "src/handles-inl.h", "src/handles.cc", "src/handles.h", + "src/hash-seed-inl.h", "src/heap-symbols.h", "src/heap/array-buffer-collector.cc", "src/heap/array-buffer-collector.h", diff --git a/src/api.cc b/src/api.cc index 3438c55d7c..718f6cb439 100644 --- a/src/api.cc +++ b/src/api.cc @@ -45,6 +45,7 @@ #include "src/gdb-jit.h" #include "src/global-handles.h" #include "src/globals.h" +#include "src/heap/heap-inl.h" #include "src/icu_util.h" #include "src/isolate-inl.h" #include "src/json-parser.h" @@ -5595,7 +5596,7 @@ Local Symbol::Name() const { i::Handle sym = Utils::OpenHandle(this); i::Isolate* isolate; - if (!i::Isolate::FromWritableHeapObject(*sym, &isolate)) { + if (!i::GetIsolateFromWritableObject(*sym, &isolate)) { // If the Symbol is in RO_SPACE, then its name must be too. Since RO_SPACE // objects are immovable we can use the Handle(Address*) constructor with // the address of the name field in the Symbol object without needing an @@ -6495,10 +6496,10 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) { return false; } - // It is safe to call FromWritable because SupportsExternalization already - // checked that the object is writable. + // It is safe to call GetIsolateFromWritableHeapObject because + // SupportsExternalization already checked that the object is writable. i::Isolate* isolate; - i::Isolate::FromWritableHeapObject(obj, &isolate); + i::GetIsolateFromWritableObject(obj, &isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); CHECK(resource && resource->data()); @@ -6524,10 +6525,10 @@ bool v8::String::MakeExternal( return false; } - // It is safe to call FromWritable because SupportsExternalization already - // checked that the object is writable. + // It is safe to call GetIsolateFromWritableHeapObject because + // SupportsExternalization already checked that the object is writable. i::Isolate* isolate; - i::Isolate::FromWritableHeapObject(obj, &isolate); + i::GetIsolateFromWritableObject(obj, &isolate); ENTER_V8_NO_SCRIPT_NO_EXCEPTION(isolate); CHECK(resource && resource->data()); diff --git a/src/arguments-inl.h b/src/arguments-inl.h index ad2b5ca87c..e596d44117 100644 --- a/src/arguments-inl.h +++ b/src/arguments-inl.h @@ -8,7 +8,7 @@ #include "src/arguments.h" #include "src/handles-inl.h" -#include "src/objects-inl.h" +#include "src/objects-inl.h" // TODO(jkummerow): Just smi-inl.h. namespace v8 { namespace internal { diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc index 856082177e..53dc242b79 100644 --- a/src/arm/macro-assembler-arm.cc +++ b/src/arm/macro-assembler-arm.cc @@ -18,6 +18,7 @@ #include "src/double.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/objects-inl.h" #include "src/register-configuration.h" diff --git a/src/arm64/macro-assembler-arm64.cc b/src/arm64/macro-assembler-arm64.cc index ea108f0155..a2caf46d71 100644 --- a/src/arm64/macro-assembler-arm64.cc +++ b/src/arm64/macro-assembler-arm64.cc @@ -15,6 +15,7 @@ #include "src/external-reference-table.h" #include "src/frame-constants.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler-inl.h" #include "src/register-configuration.h" #include "src/runtime/runtime.h" diff --git a/src/assembler.cc b/src/assembler.cc index 4643d353d2..8814d52235 100644 --- a/src/assembler.cc +++ b/src/assembler.cc @@ -37,6 +37,7 @@ #include "src/assembler-inl.h" #include "src/deoptimizer.h" #include "src/disassembler.h" +#include "src/heap/heap-inl.h" // For MemoryAllocator. TODO(jkummerow): Drop. #include "src/isolate.h" #include "src/ostreams.h" #include "src/snapshot/embedded-data.h" diff --git a/src/ast/ast.cc b/src/ast/ast.cc index c5b122cd33..c80e6f8f7a 100644 --- a/src/ast/ast.cc +++ b/src/ast/ast.cc @@ -23,6 +23,7 @@ #include "src/property-details.h" #include "src/property.h" #include "src/string-stream.h" +#include "src/zone/zone-list-inl.h" namespace v8 { namespace internal { diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index c110376b99..af31309698 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -18,7 +18,7 @@ #include "src/extensions/statistics-extension.h" #include "src/extensions/trigger-failure-extension.h" #include "src/function-kind.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" #include "src/isolate-inl.h" #include "src/math-random.h" #include "src/objects/api-callbacks.h" diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc index 9ca403743a..a4b80ed478 100644 --- a/src/builtins/arm/builtins-arm.cc +++ b/src/builtins/arm/builtins-arm.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" #include "src/objects/cell.h" diff --git a/src/builtins/arm64/builtins-arm64.cc b/src/builtins/arm64/builtins-arm64.cc index 9432c317f8..b272a23fce 100644 --- a/src/builtins/arm64/builtins-arm64.cc +++ b/src/builtins/arm64/builtins-arm64.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" #include "src/objects/cell.h" diff --git a/src/builtins/builtins-array-gen.cc b/src/builtins/builtins-array-gen.cc index c974475aac..bef80d7c19 100644 --- a/src/builtins/builtins-array-gen.cc +++ b/src/builtins/builtins-array-gen.cc @@ -12,6 +12,7 @@ #include "src/code-stub-assembler.h" #include "src/frame-constants.h" #include "src/heap/factory-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/arguments-inl.h" #include "src/objects/property-cell.h" diff --git a/src/builtins/builtins-arraybuffer.cc b/src/builtins/builtins-arraybuffer.cc index c4146a359a..a966122c97 100644 --- a/src/builtins/builtins-arraybuffer.cc +++ b/src/builtins/builtins-arraybuffer.cc @@ -6,6 +6,7 @@ #include "src/builtins/builtins.h" #include "src/conversions.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/maybe-handles-inl.h" #include "src/objects-inl.h" #include "src/objects/js-array-buffer-inl.h" diff --git a/src/builtins/builtins-boolean.cc b/src/builtins/builtins-boolean.cc index 52ed0563c6..b10f013020 100644 --- a/src/builtins/builtins-boolean.cc +++ b/src/builtins/builtins-boolean.cc @@ -5,6 +5,7 @@ #include "src/builtins/builtins-utils-inl.h" #include "src/builtins/builtins.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/objects-inl.h" namespace v8 { diff --git a/src/builtins/builtins-callsite.cc b/src/builtins/builtins-callsite.cc index 7f7699927c..51580899d2 100644 --- a/src/builtins/builtins-callsite.cc +++ b/src/builtins/builtins-callsite.cc @@ -5,6 +5,7 @@ #include "src/builtins/builtins-utils-inl.h" #include "src/builtins/builtins.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. #include "src/objects-inl.h" #include "src/objects/frame-array-inl.h" diff --git a/src/builtins/builtins-collections-gen.cc b/src/builtins/builtins-collections-gen.cc index d782f241b0..b52cd78986 100644 --- a/src/builtins/builtins-collections-gen.cc +++ b/src/builtins/builtins-collections-gen.cc @@ -9,6 +9,7 @@ #include "src/builtins/builtins-utils-gen.h" #include "src/code-stub-assembler.h" #include "src/heap/factory-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects/hash-table-inl.h" #include "src/objects/js-collection.h" #include "torque-generated/builtins-base-from-dsl-gen.h" diff --git a/src/builtins/builtins-microtask-queue-gen.cc b/src/builtins/builtins-microtask-queue-gen.cc index c60d3b659f..478943096f 100644 --- a/src/builtins/builtins-microtask-queue-gen.cc +++ b/src/builtins/builtins-microtask-queue-gen.cc @@ -9,6 +9,7 @@ #include "src/objects/js-weak-refs.h" #include "src/objects/microtask-inl.h" #include "src/objects/promise.h" +#include "src/objects/smi-inl.h" namespace v8 { namespace internal { diff --git a/src/builtins/builtins-object.cc b/src/builtins/builtins-object.cc index ab0afc0c87..6aa20e07a4 100644 --- a/src/builtins/builtins-object.cc +++ b/src/builtins/builtins-object.cc @@ -6,6 +6,7 @@ #include "src/builtins/builtins.h" #include "src/code-factory.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/keys.h" #include "src/lookup.h" #include "src/message-template.h" diff --git a/src/builtins/builtins-promise.cc b/src/builtins/builtins-promise.cc index 0f18d8fb45..f742252050 100644 --- a/src/builtins/builtins-promise.cc +++ b/src/builtins/builtins-promise.cc @@ -7,6 +7,7 @@ #include "src/builtins/builtins-utils-inl.h" #include "src/builtins/builtins.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/objects-inl.h" namespace v8 { diff --git a/src/builtins/builtins-string-gen.cc b/src/builtins/builtins-string-gen.cc index 36b9be8052..acfa3ce707 100644 --- a/src/builtins/builtins-string-gen.cc +++ b/src/builtins/builtins-string-gen.cc @@ -9,6 +9,7 @@ #include "src/builtins/builtins.h" #include "src/code-factory.h" #include "src/heap/factory-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects.h" #include "src/objects/property-cell.h" diff --git a/src/builtins/builtins-string.cc b/src/builtins/builtins-string.cc index 89901507df..d114a0e86b 100644 --- a/src/builtins/builtins-string.cc +++ b/src/builtins/builtins-string.cc @@ -6,6 +6,7 @@ #include "src/builtins/builtins.h" #include "src/conversions.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/objects-inl.h" #ifdef V8_INTL_SUPPORT #include "src/objects/intl-objects.h" diff --git a/src/builtins/builtins-symbol.cc b/src/builtins/builtins-symbol.cc index 4e4a9d8db9..66fa69afff 100644 --- a/src/builtins/builtins-symbol.cc +++ b/src/builtins/builtins-symbol.cc @@ -5,6 +5,7 @@ #include "src/builtins/builtins-utils-inl.h" #include "src/builtins/builtins.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For public_symbol_table(). #include "src/objects-inl.h" namespace v8 { diff --git a/src/builtins/builtins-trace.cc b/src/builtins/builtins-trace.cc index dc7e709cae..0cda07a27a 100644 --- a/src/builtins/builtins-trace.cc +++ b/src/builtins/builtins-trace.cc @@ -6,6 +6,7 @@ #include "src/builtins/builtins-utils-inl.h" #include "src/builtins/builtins.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/json-stringifier.h" #include "src/objects-inl.h" diff --git a/src/builtins/ia32/builtins-ia32.cc b/src/builtins/ia32/builtins-ia32.cc index c0d65940a3..daf9d5f12f 100644 --- a/src/builtins/ia32/builtins-ia32.cc +++ b/src/builtins/ia32/builtins-ia32.cc @@ -12,6 +12,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" #include "src/objects/cell.h" diff --git a/src/builtins/mips/builtins-mips.cc b/src/builtins/mips/builtins-mips.cc index 50e6d5ea4b..bbbb6d436e 100644 --- a/src/builtins/mips/builtins-mips.cc +++ b/src/builtins/mips/builtins-mips.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/mips/constants-mips.h" #include "src/objects-inl.h" diff --git a/src/builtins/mips64/builtins-mips64.cc b/src/builtins/mips64/builtins-mips64.cc index 161433b6dd..dc75f0a44d 100644 --- a/src/builtins/mips64/builtins-mips64.cc +++ b/src/builtins/mips64/builtins-mips64.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/mips64/constants-mips64.h" #include "src/objects-inl.h" diff --git a/src/builtins/ppc/builtins-ppc.cc b/src/builtins/ppc/builtins-ppc.cc index acc3b93c9f..118d63e124 100644 --- a/src/builtins/ppc/builtins-ppc.cc +++ b/src/builtins/ppc/builtins-ppc.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects/cell.h" #include "src/objects/foreign.h" diff --git a/src/builtins/s390/builtins-s390.cc b/src/builtins/s390/builtins-s390.cc index a074d9ac5e..4950626df4 100644 --- a/src/builtins/s390/builtins-s390.cc +++ b/src/builtins/s390/builtins-s390.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects/cell.h" #include "src/objects/foreign.h" diff --git a/src/builtins/setup-builtins-internal.cc b/src/builtins/setup-builtins-internal.cc index ebb8787305..842e6a6998 100644 --- a/src/builtins/setup-builtins-internal.cc +++ b/src/builtins/setup-builtins-internal.cc @@ -8,8 +8,8 @@ #include "src/builtins/builtins.h" #include "src/code-events.h" #include "src/compiler/code-assembler.h" - #include "src/handles-inl.h" +#include "src/heap/heap-inl.h" // For MemoryAllocator::code_range. #include "src/interface-descriptors.h" #include "src/interpreter/bytecodes.h" #include "src/interpreter/interpreter-generator.h" diff --git a/src/builtins/x64/builtins-x64.cc b/src/builtins/x64/builtins-x64.cc index f7e6fbd094..74c4a016cf 100644 --- a/src/builtins/x64/builtins-x64.cc +++ b/src/builtins/x64/builtins-x64.cc @@ -11,6 +11,8 @@ #include "src/deoptimizer.h" #include "src/frame-constants.h" #include "src/frames.h" +// For interpreter_entry_return_pc_offset. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/macro-assembler-inl.h" #include "src/objects-inl.h" #include "src/objects/cell.h" diff --git a/src/code-factory.cc b/src/code-factory.cc index 7303f44f2b..3c52fb0752 100644 --- a/src/code-factory.cc +++ b/src/code-factory.cc @@ -8,6 +8,7 @@ #include "src/builtins/builtins-descriptors.h" #include "src/ic/ic.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" namespace v8 { namespace internal { diff --git a/src/code-reference.cc b/src/code-reference.cc index bd7096c63e..4c8077754d 100644 --- a/src/code-reference.cc +++ b/src/code-reference.cc @@ -4,6 +4,7 @@ #include "src/code-reference.h" +#include "src/code-desc.h" #include "src/globals.h" #include "src/handles-inl.h" #include "src/objects-inl.h" diff --git a/src/code-stub-assembler.cc b/src/code-stub-assembler.cc index 7c07b9d434..ba50a7a9c3 100644 --- a/src/code-stub-assembler.cc +++ b/src/code-stub-assembler.cc @@ -9,6 +9,7 @@ #include "src/frames-inl.h" #include "src/frames.h" #include "src/function-kind.h" +#include "src/heap/heap-inl.h" // For Page/MemoryChunk. TODO(jkummerow): Drop. #include "src/objects/api-callbacks.h" #include "src/objects/cell.h" #include "src/objects/descriptor-array.h" diff --git a/src/compiler-dispatcher/compiler-dispatcher.cc b/src/compiler-dispatcher/compiler-dispatcher.cc index affb1ddd37..08c815787f 100644 --- a/src/compiler-dispatcher/compiler-dispatcher.cc +++ b/src/compiler-dispatcher/compiler-dispatcher.cc @@ -15,6 +15,7 @@ #include "src/parsing/parse-info.h" #include "src/parsing/parser.h" #include "src/task-utils.h" +#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 namespace v8 { namespace internal { diff --git a/src/compiler.cc b/src/compiler.cc index 5a408e43cd..8a63a097ec 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -40,6 +40,7 @@ #include "src/snapshot/code-serializer.h" #include "src/unoptimized-compilation-info.h" #include "src/vm-state-inl.h" +#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 namespace v8 { namespace internal { diff --git a/src/compiler/compilation-dependencies.cc b/src/compiler/compilation-dependencies.cc index ee9de6f35e..26bd88c424 100644 --- a/src/compiler/compilation-dependencies.cc +++ b/src/compiler/compilation-dependencies.cc @@ -6,6 +6,7 @@ #include "src/handles-inl.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" namespace v8 { namespace internal { diff --git a/src/compiler/js-heap-broker.cc b/src/compiler/js-heap-broker.cc index a8e8330d3c..092bb26f16 100644 --- a/src/compiler/js-heap-broker.cc +++ b/src/compiler/js-heap-broker.cc @@ -11,6 +11,7 @@ #include "src/compiler/graph-reducer.h" #include "src/compiler/per-isolate-compiler-cache.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/cell-inl.h" #include "src/objects/heap-number-inl.h" #include "src/objects/instance-type-inl.h" @@ -1452,7 +1453,7 @@ void JSObjectData::SerializeRecursive(JSHeapBroker* broker, int depth) { elements_object->map() == ReadOnlyRoots(isolate).fixed_cow_array_map(); if (empty_or_cow) { // We need to make sure copy-on-write elements are tenured. - if (Heap::InYoungGeneration(*elements_object)) { + if (ObjectInYoungGeneration(*elements_object)) { elements_object = isolate->factory()->CopyAndTenureFixedCOWArray( Handle::cast(elements_object)); boilerplate->set_elements(*elements_object); @@ -2030,7 +2031,7 @@ void JSObjectRef::EnsureElementsTenured() { AllowHeapAllocation allow_heap_allocation; Handle object_elements = elements().object(); - if (Heap::InYoungGeneration(*object_elements)) { + if (ObjectInYoungGeneration(*object_elements)) { // If we would like to pretenure a fixed cow array, we must ensure that // the array is already in old space, otherwise we'll create too many // old-to-new-space pointers (overflowing the store buffer). diff --git a/src/contexts-inl.h b/src/contexts-inl.h index c03a78d83e..07e1433200 100644 --- a/src/contexts-inl.h +++ b/src/contexts-inl.h @@ -11,6 +11,7 @@ #include "src/objects-inl.h" #include "src/objects/dictionary-inl.h" #include "src/objects/fixed-array-inl.h" +#include "src/objects/js-objects-inl.h" #include "src/objects/map-inl.h" #include "src/objects/regexp-match-info.h" #include "src/objects/scope-info.h" diff --git a/src/debug/debug.cc b/src/debug/debug.cc index af8d8f00d3..1059ff0b50 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -23,6 +23,7 @@ #include "src/frames-inl.h" #include "src/global-handles.h" #include "src/globals.h" +#include "src/heap/heap-inl.h" // For NextDebuggingId. #include "src/interpreter/bytecode-array-accessor.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/interpreter.h" diff --git a/src/deoptimizer.cc b/src/deoptimizer.cc index 361c8a0868..cf8e59c763 100644 --- a/src/deoptimizer.cc +++ b/src/deoptimizer.cc @@ -14,6 +14,7 @@ #include "src/disasm.h" #include "src/frames-inl.h" #include "src/global-handles.h" +#include "src/heap/heap-inl.h" #include "src/interpreter/interpreter.h" #include "src/log.h" #include "src/macro-assembler.h" @@ -276,7 +277,7 @@ class ActivationsFinder : public ThreadVisitor { void Deoptimizer::DeoptimizeMarkedCodeForContext(Context context) { DisallowHeapAllocation no_allocation; - Isolate* isolate = context->GetHeap()->isolate(); + Isolate* isolate = context->GetIsolate(); Code topmost_optimized_code; bool safe_to_deopt_topmost_optimized_code = false; #ifdef DEBUG diff --git a/src/elements.cc b/src/elements.cc index 2426ecbf5d..1f042b6855 100644 --- a/src/elements.cc +++ b/src/elements.cc @@ -8,6 +8,7 @@ #include "src/conversions.h" #include "src/frames.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For MaxNumberToStringCacheSize. #include "src/heap/heap-write-barrier-inl.h" #include "src/isolate-inl.h" #include "src/keys.h" @@ -2012,7 +2013,7 @@ class FastElementsAccessor : public ElementsAccessorBase { const int kMinLengthForSparsenessCheck = 64; if (backing_store->length() < kMinLengthForSparsenessCheck) return; // TODO(ulan): Check if it works with young large objects. - if (Heap::InYoungGeneration(*backing_store)) return; + if (ObjectInYoungGeneration(*backing_store)) return; uint32_t length = 0; if (obj->IsJSArray()) { JSArray::cast(*obj)->length()->ToArrayLength(&length); diff --git a/src/external-reference.cc b/src/external-reference.cc index 5512f32ab8..44efe5a6ee 100644 --- a/src/external-reference.cc +++ b/src/external-reference.cc @@ -13,7 +13,10 @@ #include "src/debug/debug.h" #include "src/deoptimizer.h" #include "src/elements.h" +#include "src/hash-seed-inl.h" #include "src/heap/heap.h" +// For IncrementalMarking::RecordWriteFromCode. TODO(jkummerow): Drop. +#include "src/heap/heap-inl.h" #include "src/ic/stub-cache.h" #include "src/interpreter/interpreter.h" #include "src/isolate.h" @@ -650,7 +653,7 @@ FUNCTION_REFERENCE(jsreceiver_create_identity_hash, static uint32_t ComputeSeededIntegerHash(Isolate* isolate, uint32_t key) { DisallowHeapAllocation no_gc; - return ComputeSeededHash(key, isolate->heap()->HashSeed()); + return ComputeSeededHash(key, HashSeed(isolate)); } FUNCTION_REFERENCE(compute_integer_hash, ComputeSeededIntegerHash) @@ -699,11 +702,6 @@ ExternalReference::search_string_raw(); template ExternalReference ExternalReference::search_string_raw(); -ExternalReference ExternalReference::page_flags(Page* page) { - return ExternalReference(reinterpret_cast
(page) + - MemoryChunk::kFlagsOffset); -} - ExternalReference ExternalReference::FromRawAddress(Address address) { return ExternalReference(address); } diff --git a/src/external-reference.h b/src/external-reference.h index f788c40f30..f22f989195 100644 --- a/src/external-reference.h +++ b/src/external-reference.h @@ -287,8 +287,6 @@ class ExternalReference { template static ExternalReference search_string_raw(); - static ExternalReference page_flags(Page* page); - static ExternalReference FromRawAddress(Address address); #define DECL_EXTERNAL_REFERENCE(name, desc) static ExternalReference name(); diff --git a/src/feedback-vector-inl.h b/src/feedback-vector-inl.h index 4def962b33..8f65d109d6 100644 --- a/src/feedback-vector-inl.h +++ b/src/feedback-vector-inl.h @@ -6,10 +6,11 @@ #define V8_FEEDBACK_VECTOR_INL_H_ #include "src/feedback-vector.h" + #include "src/globals.h" #include "src/heap/factory-inl.h" -#include "src/heap/heap-inl.h" -#include "src/heap/heap-write-barrier.h" +#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects/code-inl.h" #include "src/objects/maybe-object-inl.h" #include "src/objects/shared-function-info.h" #include "src/objects/smi.h" diff --git a/src/frames.cc b/src/frames.cc index 8b763acb2f..09f5a37d4b 100644 --- a/src/frames.cc +++ b/src/frames.cc @@ -199,7 +199,7 @@ bool IsInterpreterFramePc(Isolate* isolate, Address pc, // an InterpretedFrame, so we do these fast checks first if (StackFrame::IsTypeMarker(marker) || maybe_function->IsSmi()) { return false; - } else if (!isolate->heap()->code_space()->ContainsSlow(pc)) { + } else if (!isolate->heap()->InSpaceSlow(pc, CODE_SPACE)) { return false; } interpreter_entry_trampoline = diff --git a/src/global-handles.cc b/src/global-handles.cc index 1452718aa5..5eb3d93f14 100644 --- a/src/global-handles.cc +++ b/src/global-handles.cc @@ -8,6 +8,7 @@ #include "src/base/compiler-specific.h" #include "src/cancelable-task.h" #include "src/heap/embedder-tracing.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects-inl.h" #include "src/objects/slots.h" #include "src/task-utils.h" @@ -714,7 +715,7 @@ GlobalHandles::~GlobalHandles() { regular_nodes_.reset(nullptr); } Handle GlobalHandles::Create(Object value) { GlobalHandles::Node* result = regular_nodes_->Acquire(value); - if (Heap::InYoungGeneration(value) && !result->is_in_young_list()) { + if (ObjectInYoungGeneration(value) && !result->is_in_young_list()) { young_nodes_.push_back(result); result->set_in_young_list(true); } @@ -727,7 +728,7 @@ Handle GlobalHandles::Create(Address value) { Handle GlobalHandles::CreateTraced(Object value, Address* slot) { GlobalHandles::TracedNode* result = traced_nodes_->Acquire(value); - if (Heap::InYoungGeneration(value) && !result->is_in_young_list()) { + if (ObjectInYoungGeneration(value) && !result->is_in_young_list()) { traced_young_nodes_.push_back(result); result->set_in_young_list(true); } @@ -1060,7 +1061,7 @@ void GlobalHandles::UpdateAndCompactListOfYoungNode( for (T* node : *node_list) { DCHECK(node->is_in_young_list()); if (node->IsInUse()) { - if (Heap::InYoungGeneration(node->object())) { + if (ObjectInYoungGeneration(node->object())) { (*node_list)[last++] = node; isolate_->heap()->IncrementNodesCopiedInNewSpace(); } else { @@ -1362,7 +1363,7 @@ void EternalHandles::IterateYoungRoots(RootVisitor* visitor) { void EternalHandles::PostGarbageCollectionProcessing() { size_t last = 0; for (int index : young_node_indices_) { - if (Heap::InYoungGeneration(Object(*GetLocation(index)))) { + if (ObjectInYoungGeneration(Object(*GetLocation(index)))) { young_node_indices_[last++] = index; } } @@ -1385,7 +1386,7 @@ void EternalHandles::Create(Isolate* isolate, Object object, int* index) { } DCHECK_EQ(the_hole->ptr(), blocks_[block][offset]); blocks_[block][offset] = object->ptr(); - if (Heap::InYoungGeneration(object)) { + if (ObjectInYoungGeneration(object)) { young_node_indices_.push_back(size_); } *index = size_++; diff --git a/src/handles.cc b/src/handles.cc index 7a6c06f571..21d21be9fd 100644 --- a/src/handles.cc +++ b/src/handles.cc @@ -12,6 +12,11 @@ #include "src/objects-inl.h" #include "src/roots-inl.h" +#ifdef DEBUG +// For GetIsolateFromWritableHeapObject. +#include "src/heap/heap-write-barrier-inl.h" +#endif + namespace v8 { namespace internal { @@ -29,7 +34,7 @@ bool HandleBase::IsDereferenceAllowed(DereferenceCheckMode mode) const { if (object->IsSmi()) return true; HeapObject heap_object = HeapObject::cast(object); Isolate* isolate; - if (!Isolate::FromWritableHeapObject(heap_object, &isolate)) return true; + if (!GetIsolateFromWritableObject(heap_object, &isolate)) return true; RootIndex root_index; if (isolate->roots_table().IsRootHandleLocation(location_, &root_index) && RootsTable::IsImmortalImmovable(root_index)) { diff --git a/src/hash-seed-inl.h b/src/hash-seed-inl.h new file mode 100644 index 0000000000..b32b8296db --- /dev/null +++ b/src/hash-seed-inl.h @@ -0,0 +1,44 @@ +// Copyright 2019 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_HASH_SEED_INL_H_ +#define V8_HASH_SEED_INL_H_ + +#include + +// The #includes below currently lead to cyclic transitive includes, so +// HashSeed() ends up being required before it is defined, so we have to +// declare it here. This is a workaround; if we needed this permanently then +// we should put that line into a "hash-seed.h" header; but we won't need +// it for long. +// TODO(jkummerow): Get rid of this by breaking circular include dependencies. +namespace v8 { +namespace internal { + +class Isolate; + +inline uint64_t HashSeed(Isolate* isolate); + +} // namespace internal +} // namespace v8 + +// See comment above for why this isn't at the top of the file. +#include "src/objects/fixed-array-inl.h" +#include "src/roots-inl.h" + +namespace v8 { +namespace internal { + +inline uint64_t HashSeed(Isolate* isolate) { + uint64_t seed; + ReadOnlyRoots(isolate).hash_seed()->copy_out( + 0, reinterpret_cast(&seed), kInt64Size); + DCHECK(FLAG_randomize_hashes || seed == 0); + return seed; +} + +} // namespace internal +} // namespace v8 + +#endif // V8_HASH_SEED_INL_H_ diff --git a/src/heap/array-buffer-tracker-inl.h b/src/heap/array-buffer-tracker-inl.h index 842cccc532..04c14b15fd 100644 --- a/src/heap/array-buffer-tracker-inl.h +++ b/src/heap/array-buffer-tracker-inl.h @@ -7,8 +7,8 @@ #include "src/conversions-inl.h" #include "src/heap/array-buffer-tracker.h" -#include "src/heap/heap.h" -#include "src/heap/spaces.h" +#include "src/heap/heap-inl.h" +#include "src/heap/spaces-inl.h" #include "src/objects.h" #include "src/objects/js-array-buffer-inl.h" diff --git a/src/heap/code-stats.cc b/src/heap/code-stats.cc index d8e1001106..6c20e699fc 100644 --- a/src/heap/code-stats.cc +++ b/src/heap/code-stats.cc @@ -5,6 +5,7 @@ #include "src/heap/code-stats.h" #include "src/code-comments.h" +#include "src/heap/spaces-inl.h" // For HeapObjectIterator. #include "src/objects-inl.h" #include "src/reloc-info.h" diff --git a/src/heap/factory-inl.h b/src/heap/factory-inl.h index 46a4c31f06..25cbd06a7c 100644 --- a/src/heap/factory-inl.h +++ b/src/heap/factory-inl.h @@ -12,8 +12,10 @@ #include "src/handles-inl.h" #include "src/isolate-inl.h" #include "src/objects-inl.h" +#include "src/objects/feedback-cell.h" #include "src/objects/heap-number-inl.h" #include "src/objects/oddball.h" +#include "src/objects/string-inl.h" #include "src/string-hasher.h" namespace v8 { diff --git a/src/heap/factory.cc b/src/heap/factory.cc index f42ce58123..31850cb42d 100644 --- a/src/heap/factory.cc +++ b/src/heap/factory.cc @@ -14,11 +14,15 @@ #include "src/compiler.h" #include "src/conversions.h" #include "src/counters.h" +#include "src/hash-seed-inl.h" +#include "src/heap/heap-inl.h" +#include "src/heap/incremental-marking.h" #include "src/heap/mark-compact-inl.h" #include "src/ic/handler-configuration-inl.h" #include "src/interpreter/interpreter.h" #include "src/isolate-inl.h" #include "src/log.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/api-callbacks.h" #include "src/objects/arguments-inl.h" #include "src/objects/bigint.h" @@ -607,12 +611,12 @@ Handle Factory::NewAccessorPair() { // Internalized strings are created in the old generation (data space). Handle Factory::InternalizeUtf8String(Vector string) { - Utf8StringKey key(string, isolate()->heap()->HashSeed()); + Utf8StringKey key(string, HashSeed(isolate())); return InternalizeStringWithKey(&key); } Handle Factory::InternalizeOneByteString(Vector string) { - OneByteStringKey key(string, isolate()->heap()->HashSeed()); + OneByteStringKey key(string, HashSeed(isolate())); return InternalizeStringWithKey(&key); } @@ -623,7 +627,7 @@ Handle Factory::InternalizeOneByteString( } Handle Factory::InternalizeTwoByteString(Vector string) { - TwoByteStringKey key(string, isolate()->heap()->HashSeed()); + TwoByteStringKey key(string, HashSeed(isolate())); return InternalizeStringWithKey(&key); } diff --git a/src/heap/heap-controller.cc b/src/heap/heap-controller.cc index d515199518..41ffa7b1a3 100644 --- a/src/heap/heap-controller.cc +++ b/src/heap/heap-controller.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "src/heap/heap-controller.h" + +#include "src/heap/spaces.h" #include "src/isolate-inl.h" namespace v8 { @@ -73,7 +75,7 @@ size_t MemoryController::CalculateAllocationLimit( double factor = GrowingFactor(gc_speed, mutator_speed, max_factor); if (FLAG_trace_gc_verbose) { - heap_->isolate()->PrintWithTimestamp( + Isolate::FromHeap(heap_)->PrintWithTimestamp( "%s factor %.1f based on mu=%.3f, speed_ratio=%.f " "(gc=%.f, mutator=%.f)\n", ControllerName(), factor, target_mutator_utilization_, @@ -104,7 +106,7 @@ size_t MemoryController::CalculateAllocationLimit( size_t result = static_cast(Min(limit, halfway_to_the_max)); if (FLAG_trace_gc_verbose) { - heap_->isolate()->PrintWithTimestamp( + Isolate::FromHeap(heap_)->PrintWithTimestamp( "%s Limit: old size: %" PRIuS " KB, new limit: %" PRIuS " KB (%.1f)\n", ControllerName(), curr_size / KB, result / KB, factor); } diff --git a/src/heap/heap-inl.h b/src/heap/heap-inl.h index 1819e7936d..4c9a3176a5 100644 --- a/src/heap/heap-inl.h +++ b/src/heap/heap-inl.h @@ -294,19 +294,6 @@ void Heap::RegisterExternalString(String string) { external_string_table_.AddString(string); } -void Heap::UpdateExternalString(String string, size_t old_payload, - size_t new_payload) { - DCHECK(string->IsExternalString()); - Page* page = Page::FromHeapObject(string); - - if (old_payload > new_payload) - page->DecrementExternalBackingStoreBytes( - ExternalBackingStoreType::kExternalString, old_payload - new_payload); - else - page->IncrementExternalBackingStoreBytes( - ExternalBackingStoreType::kExternalString, new_payload - old_payload); -} - void Heap::FinalizeExternalString(String string) { DCHECK(string->IsExternalString()); Page* page = Page::FromHeapObject(string); @@ -553,14 +540,6 @@ Oddball Heap::ToBoolean(bool condition) { return condition ? roots.true_value() : roots.false_value(); } -uint64_t Heap::HashSeed() { - uint64_t seed; - ReadOnlyRoots(this).hash_seed()->copy_out(0, reinterpret_cast(&seed), - kInt64Size); - DCHECK(FLAG_randomize_hashes || seed == 0); - return seed; -} - int Heap::NextScriptId() { int last_id = last_script_id()->value(); if (last_id == Smi::kMaxValue) last_id = v8::UnboundScript::kNoScriptId; diff --git a/src/heap/heap-write-barrier-inl.h b/src/heap/heap-write-barrier-inl.h index a4c5e2bd3d..63d16ca82d 100644 --- a/src/heap/heap-write-barrier-inl.h +++ b/src/heap/heap-write-barrier-inl.h @@ -11,8 +11,11 @@ #include "src/heap/heap-write-barrier.h" #include "src/globals.h" -#include "src/heap/heap.h" +// TODO(jkummerow): Get rid of this by moving GetIsolateFromWritableObject +// elsewhere. +#include "src/isolate.h" #include "src/objects/code.h" +#include "src/objects/fixed-array.h" #include "src/objects/heap-object.h" #include "src/objects/maybe-object-inl.h" #include "src/objects/slots.h" @@ -20,14 +23,48 @@ namespace v8 { namespace internal { +// Defined in heap.cc. +V8_EXPORT_PRIVATE bool Heap_PageFlagsAreConsistent(HeapObject object); +V8_EXPORT_PRIVATE void Heap_GenerationalBarrierSlow(HeapObject object, + Address slot, + HeapObject value); +V8_EXPORT_PRIVATE void Heap_MarkingBarrierSlow(HeapObject object, Address slot, + HeapObject value); +V8_EXPORT_PRIVATE void Heap_WriteBarrierForCodeSlow(Code host); +V8_EXPORT_PRIVATE void Heap_GenerationalBarrierForCodeSlow(Code host, + RelocInfo* rinfo, + HeapObject object); +V8_EXPORT_PRIVATE void Heap_MarkingBarrierForCodeSlow(Code host, + RelocInfo* rinfo, + HeapObject object); +V8_EXPORT_PRIVATE void Heap_GenerationalBarrierForElementsSlow(Heap* heap, + FixedArray array, + int offset, + int length); +V8_EXPORT_PRIVATE void Heap_MarkingBarrierForElementsSlow(Heap* heap, + HeapObject object); +V8_EXPORT_PRIVATE void Heap_MarkingBarrierForDescriptorArraySlow( + Heap* heap, HeapObject host, HeapObject descriptor_array, + int number_of_own_descriptors); + // Do not use these internal details anywhere outside of this file. These // internals are only intended to shortcut write barrier checks. namespace heap_internals { +struct Space { + static constexpr uintptr_t kIdOffset = 9 * kSystemPointerSize; + V8_INLINE AllocationSpace identity() { + return *reinterpret_cast(reinterpret_cast
(this) + + kIdOffset); + } +}; + struct MemoryChunk { static constexpr uintptr_t kFlagsOffset = sizeof(size_t); static constexpr uintptr_t kHeapOffset = kFlagsOffset + kUIntptrSize + 4 * kSystemPointerSize; + static constexpr uintptr_t kOwnerOffset = + kHeapOffset + 2 * kSystemPointerSize; static constexpr uintptr_t kMarkingBit = uintptr_t{1} << 18; static constexpr uintptr_t kFromPageBit = uintptr_t{1} << 3; static constexpr uintptr_t kToPageBit = uintptr_t{1} << 4; @@ -55,31 +92,37 @@ struct MemoryChunk { SLOW_DCHECK(heap != nullptr); return heap; } + + V8_INLINE Space* GetOwner() { + return *reinterpret_cast(reinterpret_cast
(this) + + kOwnerOffset); + } }; inline void GenerationalBarrierInternal(HeapObject object, Address slot, HeapObject value) { - DCHECK(Heap::PageFlagsAreConsistent(object)); + DCHECK(Heap_PageFlagsAreConsistent(object)); heap_internals::MemoryChunk* value_chunk = heap_internals::MemoryChunk::FromHeapObject(value); heap_internals::MemoryChunk* object_chunk = heap_internals::MemoryChunk::FromHeapObject(object); - if (!value_chunk->InYoungGeneration() || object_chunk->InYoungGeneration()) + if (!value_chunk->InYoungGeneration() || object_chunk->InYoungGeneration()) { return; + } - Heap::GenerationalBarrierSlow(object, slot, value); + Heap_GenerationalBarrierSlow(object, slot, value); } inline void MarkingBarrierInternal(HeapObject object, Address slot, HeapObject value) { - DCHECK(Heap::PageFlagsAreConsistent(object)); + DCHECK(Heap_PageFlagsAreConsistent(object)); heap_internals::MemoryChunk* value_chunk = heap_internals::MemoryChunk::FromHeapObject(value); if (!value_chunk->IsMarking()) return; - Heap::MarkingBarrierSlow(object, slot, value); + Heap_MarkingBarrierSlow(object, slot, value); } } // namespace heap_internals @@ -93,7 +136,7 @@ inline void WriteBarrierForCode(Code host, RelocInfo* rinfo, Object value) { } inline void WriteBarrierForCode(Code host) { - Heap::WriteBarrierForCodeSlow(host); + Heap_WriteBarrierForCodeSlow(host); } inline void GenerationalBarrier(HeapObject object, ObjectSlot slot, @@ -119,7 +162,7 @@ inline void GenerationalBarrierForElements(Heap* heap, FixedArray array, heap_internals::MemoryChunk::FromHeapObject(array); if (array_chunk->InYoungGeneration()) return; - Heap::GenerationalBarrierForElementsSlow(heap, array, offset, length); + Heap_GenerationalBarrierForElementsSlow(heap, array, offset, length); } inline void GenerationalBarrierForCode(Code host, RelocInfo* rinfo, @@ -127,7 +170,7 @@ inline void GenerationalBarrierForCode(Code host, RelocInfo* rinfo, heap_internals::MemoryChunk* object_chunk = heap_internals::MemoryChunk::FromHeapObject(object); if (!object_chunk->InYoungGeneration()) return; - Heap::GenerationalBarrierForCodeSlow(host, rinfo, object); + Heap_GenerationalBarrierForCodeSlow(host, rinfo, object); } inline void MarkingBarrier(HeapObject object, ObjectSlot slot, Object value) { @@ -151,7 +194,7 @@ inline void MarkingBarrierForElements(Heap* heap, HeapObject object) { heap_internals::MemoryChunk::FromHeapObject(object); if (!object_chunk->IsMarking()) return; - Heap::MarkingBarrierForElementsSlow(heap, object); + Heap_MarkingBarrierForElementsSlow(heap, object); } inline void MarkingBarrierForCode(Code host, RelocInfo* rinfo, @@ -160,7 +203,7 @@ inline void MarkingBarrierForCode(Code host, RelocInfo* rinfo, heap_internals::MemoryChunk* object_chunk = heap_internals::MemoryChunk::FromHeapObject(object); if (!object_chunk->IsMarking()) return; - Heap::MarkingBarrierForCodeSlow(host, rinfo, object); + Heap_MarkingBarrierForCodeSlow(host, rinfo, object); } inline void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host, @@ -170,8 +213,24 @@ inline void MarkingBarrierForDescriptorArray(Heap* heap, HeapObject host, heap_internals::MemoryChunk::FromHeapObject(descriptor_array); if (!chunk->IsMarking()) return; - Heap::MarkingBarrierForDescriptorArraySlow(heap, host, descriptor_array, - number_of_own_descriptors); + Heap_MarkingBarrierForDescriptorArraySlow(heap, host, descriptor_array, + number_of_own_descriptors); +} + +inline WriteBarrierMode GetWriteBarrierModeForObject( + HeapObject object, const DisallowHeapAllocation* promise) { + DCHECK(Heap_PageFlagsAreConsistent(object)); + heap_internals::MemoryChunk* chunk = + heap_internals::MemoryChunk::FromHeapObject(object); + if (chunk->IsMarking()) return UPDATE_WRITE_BARRIER; + if (chunk->InYoungGeneration()) return SKIP_WRITE_BARRIER; + return UPDATE_WRITE_BARRIER; +} + +inline bool ObjectInYoungGeneration(const Object object) { + if (object.IsSmi()) return false; + return heap_internals::MemoryChunk::FromHeapObject(HeapObject::cast(object)) + ->InYoungGeneration(); } inline Heap* GetHeapFromWritableObject(const HeapObject object) { @@ -180,6 +239,17 @@ inline Heap* GetHeapFromWritableObject(const HeapObject object) { return chunk->GetHeap(); } +inline bool GetIsolateFromWritableObject(HeapObject obj, Isolate** isolate) { + heap_internals::MemoryChunk* chunk = + heap_internals::MemoryChunk::FromHeapObject(obj); + if (chunk->GetOwner()->identity() == RO_SPACE) { + *isolate = nullptr; + return false; + } + *isolate = Isolate::FromHeap(chunk->GetHeap()); + return true; +} + } // namespace internal } // namespace v8 diff --git a/src/heap/heap.cc b/src/heap/heap.cc index bff16fd90d..a61c182c2e 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -75,6 +75,52 @@ namespace v8 { namespace internal { +// These are outside the Heap class so they can be forward-declared +// in heap-write-barrier-inl.h. +bool Heap_PageFlagsAreConsistent(HeapObject object) { + return Heap::PageFlagsAreConsistent(object); +} + +void Heap_GenerationalBarrierSlow(HeapObject object, Address slot, + HeapObject value) { + Heap::GenerationalBarrierSlow(object, slot, value); +} + +void Heap_MarkingBarrierSlow(HeapObject object, Address slot, + HeapObject value) { + Heap::MarkingBarrierSlow(object, slot, value); +} + +void Heap_WriteBarrierForCodeSlow(Code host) { + Heap::WriteBarrierForCodeSlow(host); +} + +void Heap_GenerationalBarrierForCodeSlow(Code host, RelocInfo* rinfo, + HeapObject object) { + Heap::GenerationalBarrierForCodeSlow(host, rinfo, object); +} + +void Heap_MarkingBarrierForCodeSlow(Code host, RelocInfo* rinfo, + HeapObject object) { + Heap::MarkingBarrierForCodeSlow(host, rinfo, object); +} + +void Heap_GenerationalBarrierForElementsSlow(Heap* heap, FixedArray array, + int offset, int length) { + Heap::GenerationalBarrierForElementsSlow(heap, array, offset, length); +} + +void Heap_MarkingBarrierForElementsSlow(Heap* heap, HeapObject object) { + Heap::MarkingBarrierForElementsSlow(heap, object); +} + +void Heap_MarkingBarrierForDescriptorArraySlow(Heap* heap, HeapObject host, + HeapObject descriptor_array, + int number_of_own_descriptors) { + Heap::MarkingBarrierForDescriptorArraySlow(heap, host, descriptor_array, + number_of_own_descriptors); +} + void Heap::SetArgumentsAdaptorDeoptPCOffset(int pc_offset) { DCHECK_EQ(Smi::kZero, arguments_adaptor_deopt_pc_offset()); set_arguments_adaptor_deopt_pc_offset(Smi::FromInt(pc_offset)); @@ -2095,6 +2141,20 @@ bool Heap::ExternalStringTable::Contains(String string) { return false; } +void Heap::UpdateExternalString(String string, size_t old_payload, + size_t new_payload) { + DCHECK(string->IsExternalString()); + Page* page = Page::FromHeapObject(string); + + if (old_payload > new_payload) { + page->DecrementExternalBackingStoreBytes( + ExternalBackingStoreType::kExternalString, old_payload - new_payload); + } else { + page->IncrementExternalBackingStoreBytes( + ExternalBackingStoreType::kExternalString, new_payload - old_payload); + } +} + String Heap::UpdateYoungReferenceInExternalStringTableEntry(Heap* heap, FullObjectSlot p) { HeapObject obj = HeapObject::cast(*p); @@ -5807,6 +5867,9 @@ static_assert(MemoryChunk::kFlagsOffset == static_assert(MemoryChunk::kHeapOffset == heap_internals::MemoryChunk::kHeapOffset, "Heap offset inconsistent"); +static_assert(MemoryChunk::kOwnerOffset == + heap_internals::MemoryChunk::kOwnerOffset, + "Owner offset inconsistent"); void Heap::SetEmbedderStackStateForNextFinalizaton( EmbedderHeapTracer::EmbedderStackState stack_state) { diff --git a/src/heap/heap.h b/src/heap/heap.h index 80748099c7..71d82292d0 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -509,8 +509,6 @@ class Heap { void IncrementDeferredCount(v8::Isolate::UseCounterFeature feature); - inline uint64_t HashSeed(); - inline int NextScriptId(); inline int NextDebuggingId(); inline int GetNextTemplateSerialNumber(); @@ -894,8 +892,8 @@ class Heap { // Called when a string's resource is changed. The size of the payload is sent // as argument of the method. - inline void UpdateExternalString(String string, size_t old_payload, - size_t new_payload); + void UpdateExternalString(String string, size_t old_payload, + size_t new_payload); // Finalizes an external string by deleting the associated external // data and clearing the resource pointer. diff --git a/src/heap/mark-compact-inl.h b/src/heap/mark-compact-inl.h index 3245e13132..a4fbf06c10 100644 --- a/src/heap/mark-compact-inl.h +++ b/src/heap/mark-compact-inl.h @@ -5,9 +5,12 @@ #ifndef V8_HEAP_MARK_COMPACT_INL_H_ #define V8_HEAP_MARK_COMPACT_INL_H_ +#include "src/heap/mark-compact.h" + #include "src/assembler-inl.h" #include "src/base/bits.h" -#include "src/heap/mark-compact.h" +#include "src/heap/heap-inl.h" +#include "src/heap/incremental-marking.h" #include "src/heap/objects-visiting-inl.h" #include "src/heap/remembered-set.h" #include "src/objects/js-collection-inl.h" diff --git a/src/heap/setup-heap-internal.cc b/src/heap/setup-heap-internal.cc index 9975e2f451..4280fc0bed 100644 --- a/src/heap/setup-heap-internal.cc +++ b/src/heap/setup-heap-internal.cc @@ -9,7 +9,7 @@ #include "src/contexts.h" #include "src/heap-symbols.h" #include "src/heap/factory.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" #include "src/ic/handler-configuration.h" #include "src/interpreter/interpreter.h" #include "src/isolate.h" diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h index 30f897a9e7..c7a4ebf754 100644 --- a/src/heap/spaces-inl.h +++ b/src/heap/spaces-inl.h @@ -5,11 +5,13 @@ #ifndef V8_HEAP_SPACES_INL_H_ #define V8_HEAP_SPACES_INL_H_ +#include "src/heap/spaces.h" + #include "src/base/atomic-utils.h" #include "src/base/bounded-page-allocator.h" #include "src/base/v8-fallthrough.h" +#include "src/heap/heap-inl.h" #include "src/heap/incremental-marking.h" -#include "src/heap/spaces.h" #include "src/msan.h" #include "src/objects/code-inl.h" diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index fd25874f27..f187b3966f 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -670,6 +670,8 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size, } DCHECK_EQ(kFlagsOffset, OFFSET_OF(MemoryChunk, flags_)); + DCHECK_EQ(kHeapOffset, OFFSET_OF(MemoryChunk, heap_)); + DCHECK_EQ(kOwnerOffset, OFFSET_OF(MemoryChunk, owner_)); if (executable == EXECUTABLE) { chunk->SetFlag(IS_EXECUTABLE); @@ -1464,6 +1466,12 @@ void MemoryChunk::ReleaseMarkingBitmap() { // ----------------------------------------------------------------------------- // PagedSpace implementation +void Space::CheckOffsetsAreConsistent() const { + static_assert(Space::kIdOffset == heap_internals::Space::kIdOffset, + "ID offset inconsistent"); + DCHECK_EQ(Space::kIdOffset, OFFSET_OF(Space, id_)); +} + void Space::AddAllocationObserver(AllocationObserver* observer) { allocation_observers_.push_back(observer); StartNextInlineAllocationStep(); diff --git a/src/heap/spaces.h b/src/heap/spaces.h index e9fe19a490..c7bff3448e 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -114,11 +114,6 @@ class Space; // Some assertion macros used in the debugging mode. -#define DCHECK_PAGE_ALIGNED(address) DCHECK_EQ(0, (address)&kPageAlignmentMask) - -#define DCHECK_OBJECT_ALIGNED(address) \ - DCHECK_EQ(0, (address)&kObjectAlignmentMask) - #define DCHECK_OBJECT_SIZE(size) \ DCHECK((0 < size) && (size <= kMaxRegularHeapObjectSize)) @@ -370,6 +365,8 @@ class MemoryChunk { kReservationOffset + 3 * kSystemPointerSize; static const intptr_t kHeaderSentinelOffset = kHeapOffset + kSystemPointerSize; + static const intptr_t kOwnerOffset = + kHeaderSentinelOffset + kSystemPointerSize; static const size_t kHeaderSize = kSizeOffset // NOLINT @@ -709,13 +706,13 @@ class MemoryChunk { // guaranteed to not contain such a pointer. Address header_sentinel_; + // The space owning this memory chunk. + std::atomic owner_; + // Start and end of allocatable memory on this chunk. Address area_start_; Address area_end_; - // The space owning this memory chunk. - std::atomic owner_; - // Used by the incremental marker to keep track of the scanning progress in // large objects that have a progress bar and are scanned in increments. std::atomic progress_bar_; @@ -981,8 +978,11 @@ class Space : public Malloced { external_backing_store_bytes_[ExternalBackingStoreType::kArrayBuffer] = 0; external_backing_store_bytes_[ExternalBackingStoreType::kExternalString] = 0; + CheckOffsetsAreConsistent(); } + void CheckOffsetsAreConsistent() const; + static inline void MoveExternalBackingStoreBytes( ExternalBackingStoreType type, Space* from, Space* to, size_t amount); @@ -1092,6 +1092,8 @@ class Space : public Malloced { std::atomic* external_backing_store_bytes_; private: + static const intptr_t kIdOffset = 9 * kSystemPointerSize; + bool allocation_observers_paused_; Heap* heap_; AllocationSpace id_; diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc index 2bde18e0fd..55ab4094f9 100644 --- a/src/ia32/macro-assembler-ia32.cc +++ b/src/ia32/macro-assembler-ia32.cc @@ -15,6 +15,7 @@ #include "src/external-reference-table.h" #include "src/frame-constants.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/ia32/assembler-ia32-inl.h" #include "src/macro-assembler.h" #include "src/runtime/runtime.h" diff --git a/src/ic/stub-cache.cc b/src/ic/stub-cache.cc index 98fd15a690..0c037f5775 100644 --- a/src/ic/stub-cache.cc +++ b/src/ic/stub-cache.cc @@ -7,7 +7,7 @@ #include "src/ast/ast.h" #include "src/base/bits.h" #include "src/counters.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" // For InYoungGeneration(). #include "src/ic/ic-inl.h" namespace v8 { diff --git a/src/isolate-inl.h b/src/isolate-inl.h index e2b0bb728d..b61f19d395 100644 --- a/src/isolate-inl.h +++ b/src/isolate-inl.h @@ -5,7 +5,6 @@ #ifndef V8_ISOLATE_INL_H_ #define V8_ISOLATE_INL_H_ -#include "src/heap/heap-inl.h" // Need MemoryChunk from heap/spaces.h #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/cell-inl.h" @@ -21,16 +20,6 @@ IsolateAllocationMode Isolate::isolate_allocation_mode() { return isolate_allocator_->mode(); } -bool Isolate::FromWritableHeapObject(HeapObject obj, Isolate** isolate) { - i::MemoryChunk* chunk = i::MemoryChunk::FromHeapObject(obj); - if (chunk->owner()->identity() == i::RO_SPACE) { - *isolate = nullptr; - return false; - } - *isolate = chunk->heap()->isolate(); - return true; -} - void Isolate::set_context(Context context) { DCHECK(context.is_null() || context->IsContext()); thread_local_top_.context_ = context; @@ -128,7 +117,8 @@ NATIVE_CONTEXT_FIELDS(NATIVE_CONTEXT_FIELD_ACCESSOR) #undef NATIVE_CONTEXT_FIELD_ACCESSOR bool Isolate::IsArrayConstructorIntact() { - Cell array_constructor_cell = heap()->array_constructor_protector(); + Cell array_constructor_cell = + Cell::cast(root(RootIndex::kArrayConstructorProtector)); return array_constructor_cell->value() == Smi::FromInt(kProtectorValid); } @@ -145,56 +135,65 @@ bool Isolate::IsArraySpeciesLookupChainIntact() { // done here. In place, there are mjsunit tests harmony/array-species* which // ensure that behavior is correct in various invalid protector cases. - PropertyCell species_cell = heap()->array_species_protector(); + PropertyCell species_cell = + PropertyCell::cast(root(RootIndex::kArraySpeciesProtector)); return species_cell->value()->IsSmi() && Smi::ToInt(species_cell->value()) == kProtectorValid; } bool Isolate::IsTypedArraySpeciesLookupChainIntact() { - PropertyCell species_cell = heap()->typed_array_species_protector(); + PropertyCell species_cell = + PropertyCell::cast(root(RootIndex::kTypedArraySpeciesProtector)); return species_cell->value()->IsSmi() && Smi::ToInt(species_cell->value()) == kProtectorValid; } bool Isolate::IsRegExpSpeciesLookupChainIntact() { - PropertyCell species_cell = heap()->regexp_species_protector(); + PropertyCell species_cell = + PropertyCell::cast(root(RootIndex::kRegExpSpeciesProtector)); return species_cell->value()->IsSmi() && Smi::ToInt(species_cell->value()) == kProtectorValid; } bool Isolate::IsPromiseSpeciesLookupChainIntact() { - PropertyCell species_cell = heap()->promise_species_protector(); + PropertyCell species_cell = + PropertyCell::cast(root(RootIndex::kPromiseSpeciesProtector)); return species_cell->value()->IsSmi() && Smi::ToInt(species_cell->value()) == kProtectorValid; } bool Isolate::IsStringLengthOverflowIntact() { - Cell string_length_cell = heap()->string_length_protector(); + Cell string_length_cell = Cell::cast(root(RootIndex::kStringLengthProtector)); return string_length_cell->value() == Smi::FromInt(kProtectorValid); } bool Isolate::IsArrayBufferDetachingIntact() { - PropertyCell buffer_detaching = heap()->array_buffer_detaching_protector(); + PropertyCell buffer_detaching = + PropertyCell::cast(root(RootIndex::kArrayBufferDetachingProtector)); return buffer_detaching->value() == Smi::FromInt(kProtectorValid); } bool Isolate::IsArrayIteratorLookupChainIntact() { - PropertyCell array_iterator_cell = heap()->array_iterator_protector(); + PropertyCell array_iterator_cell = + PropertyCell::cast(root(RootIndex::kArrayIteratorProtector)); return array_iterator_cell->value() == Smi::FromInt(kProtectorValid); } bool Isolate::IsMapIteratorLookupChainIntact() { - PropertyCell map_iterator_cell = heap()->map_iterator_protector(); + PropertyCell map_iterator_cell = + PropertyCell::cast(root(RootIndex::kMapIteratorProtector)); return map_iterator_cell->value() == Smi::FromInt(kProtectorValid); } bool Isolate::IsSetIteratorLookupChainIntact() { - PropertyCell set_iterator_cell = heap()->set_iterator_protector(); + PropertyCell set_iterator_cell = + PropertyCell::cast(root(RootIndex::kSetIteratorProtector)); return set_iterator_cell->value() == Smi::FromInt(kProtectorValid); } bool Isolate::IsStringIteratorLookupChainIntact() { - PropertyCell string_iterator_cell = heap()->string_iterator_protector(); + PropertyCell string_iterator_cell = + PropertyCell::cast(root(RootIndex::kStringIteratorProtector)); return string_iterator_cell->value() == Smi::FromInt(kProtectorValid); } diff --git a/src/isolate.cc b/src/isolate.cc index dd60a0d7f9..5a825f5f22 100644 --- a/src/isolate.cc +++ b/src/isolate.cc @@ -35,6 +35,8 @@ #include "src/deoptimizer.h" #include "src/elements.h" #include "src/frames-inl.h" +#include "src/hash-seed-inl.h" +#include "src/heap/heap-inl.h" #include "src/ic/stub-cache.h" #include "src/interpreter/interpreter.h" #include "src/isolate-inl.h" @@ -52,6 +54,7 @@ #include "src/objects/smi.h" #include "src/objects/stack-frame-info-inl.h" #include "src/ostreams.h" +#include "src/profiler/heap-profiler.h" #include "src/profiler/tracing-cpu-profiler.h" #include "src/prototype.h" #include "src/ptr-compr.h" @@ -3472,7 +3475,7 @@ bool Isolate::Init(StartupDeserializer* des) { { HandleScope scope(this); - ast_string_constants_ = new AstStringConstants(this, heap()->HashSeed()); + ast_string_constants_ = new AstStringConstants(this, HashSeed(this)); } initialized_from_snapshot_ = (des != nullptr); diff --git a/src/isolate.h b/src/isolate.h index 9c9f8d3d60..23d035030f 100644 --- a/src/isolate.h +++ b/src/isolate.h @@ -608,11 +608,6 @@ class Isolate final : private HiddenFactory { return isolate; } - // Get the isolate that the given HeapObject lives in, returning true on - // success. If the object is not writable (i.e. lives in read-only space), - // return false. - inline static bool FromWritableHeapObject(HeapObject obj, Isolate** isolate); - // Usually called by Init(), but can be called early e.g. to allow // testing components that require logging but not the whole // isolate. @@ -970,6 +965,10 @@ class Isolate final : private HiddenFactory { } StackGuard* stack_guard() { return &stack_guard_; } Heap* heap() { return &heap_; } + static Isolate* FromHeap(Heap* heap) { + return reinterpret_cast(reinterpret_cast
(heap) - + OFFSET_OF(Isolate, heap_)); + } const IsolateData* isolate_data() const { return &isolate_data_; } IsolateData* isolate_data() { return &isolate_data_; } @@ -1924,11 +1923,9 @@ class Isolate final : private HiddenFactory { DISALLOW_COPY_AND_ASSIGN(Isolate); }; - #undef FIELD_ACCESSOR #undef THREAD_LOCAL_TOP_ACCESSOR - class PromiseOnStack { public: PromiseOnStack(Handle promise, PromiseOnStack* prev) diff --git a/src/json-parser.cc b/src/json-parser.cc index 8b2f99d7cd..f62cdba880 100644 --- a/src/json-parser.cc +++ b/src/json-parser.cc @@ -8,6 +8,8 @@ #include "src/conversions.h" #include "src/debug/debug.h" #include "src/field-type.h" +#include "src/hash-seed-inl.h" +#include "src/heap/heap-inl.h" // For string_table(). #include "src/message-template.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" @@ -839,8 +841,7 @@ Handle JsonParser::ScanJsonString() { int position = position_; uc32 c0 = c0_; - uint32_t running_hash = - static_cast(isolate()->heap()->HashSeed()); + uint32_t running_hash = static_cast(HashSeed(isolate())); uint32_t index = 0; bool is_array_index = true; diff --git a/src/log.cc b/src/log.cc index 1de85d0138..c4c285958f 100644 --- a/src/log.cc +++ b/src/log.cc @@ -1759,7 +1759,8 @@ static int EnumerateWasmModuleObjects( if (obj->IsWasmModuleObject()) { WasmModuleObject module = WasmModuleObject::cast(obj); if (module_objects != nullptr) { - module_objects[module_objects_count] = handle(module, heap->isolate()); + module_objects[module_objects_count] = + handle(module, Isolate::FromHeap(heap)); } module_objects_count++; } diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index e0de62e1da..0794590bcb 100644 --- a/src/mips/macro-assembler-mips.cc +++ b/src/mips/macro-assembler-mips.cc @@ -16,6 +16,7 @@ #include "src/debug/debug.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/objects/heap-number.h" #include "src/register-configuration.h" diff --git a/src/mips64/macro-assembler-mips64.cc b/src/mips64/macro-assembler-mips64.cc index 748aa18dda..1f120b764e 100644 --- a/src/mips64/macro-assembler-mips64.cc +++ b/src/mips64/macro-assembler-mips64.cc @@ -16,6 +16,7 @@ #include "src/debug/debug.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/objects/heap-number.h" #include "src/register-configuration.h" diff --git a/src/objects-debug.cc b/src/objects-debug.cc index 3db8334c14..943fde7499 100644 --- a/src/objects-debug.cc +++ b/src/objects-debug.cc @@ -12,9 +12,11 @@ #include "src/disassembler.h" #include "src/elements.h" #include "src/field-type.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/ic/handler-configuration-inl.h" #include "src/layout-descriptor.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/arguments-inl.h" #include "src/objects/bigint.h" #include "src/objects/cell-inl.h" @@ -635,12 +637,12 @@ void JSObject::JSObjectVerify(Isolate* isolate) { void Map::MapVerify(Isolate* isolate) { Heap* heap = isolate->heap(); - CHECK(!Heap::InYoungGeneration(*this)); + CHECK(!ObjectInYoungGeneration(*this)); CHECK(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE); CHECK(instance_size() == kVariableSizeSentinel || (kTaggedSize <= instance_size() && static_cast(instance_size()) < heap->Capacity())); - CHECK(GetBackPointer()->IsUndefined(heap->isolate()) || + CHECK(GetBackPointer()->IsUndefined(isolate) || !Map::cast(GetBackPointer())->is_stable()); HeapObject::VerifyHeapPointer(isolate, prototype()); HeapObject::VerifyHeapPointer(isolate, instance_descriptors()); @@ -991,7 +993,7 @@ void String::StringVerify(Isolate* isolate) { CHECK(length() >= 0 && length() <= Smi::kMaxValue); CHECK_IMPLIES(length() == 0, *this == ReadOnlyRoots(isolate).empty_string()); if (IsInternalizedString()) { - CHECK(!Heap::InYoungGeneration(*this)); + CHECK(!ObjectInYoungGeneration(*this)); } if (IsConsString()) { ConsString::cast(*this)->ConsStringVerify(isolate); diff --git a/src/objects-inl.h b/src/objects-inl.h index 0ac1a1f305..1a9d60144e 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -21,12 +21,13 @@ #include "src/double.h" #include "src/handles-inl.h" #include "src/heap/factory.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/keys.h" -#include "src/lookup-inl.h" +#include "src/lookup-inl.h" // TODO(jkummerow): Drop. #include "src/objects/bigint.h" #include "src/objects/heap-number-inl.h" #include "src/objects/heap-object.h" -#include "src/objects/js-proxy-inl.h" +#include "src/objects/js-proxy-inl.h" // TODO(jkummerow): Drop. #include "src/objects/literal-objects.h" #include "src/objects/oddball.h" #include "src/objects/regexp-match-info.h" @@ -81,10 +82,6 @@ bool HeapObject::IsDataHandler() const { bool HeapObject::IsClassBoilerplate() const { return IsFixedArrayExact(); } -bool HeapObject::IsExternal(Isolate* isolate) const { - return map()->FindRootMap(isolate) == isolate->heap()->external_map(); -} - #define IS_TYPE_FUNCTION_DEF(type_) \ bool Object::Is##type_() const { \ return IsHeapObject() && HeapObject::cast(*this)->Is##type_(); \ @@ -395,7 +392,6 @@ bool Object::IsMinusZero() const { i::IsMinusZero(HeapNumber::cast(*this)->value()); } -OBJECT_CONSTRUCTORS_IMPL(HeapObject, Object) OBJECT_CONSTRUCTORS_IMPL(RegExpMatchInfo, FixedArray) OBJECT_CONSTRUCTORS_IMPL(ScopeInfo, FixedArray) OBJECT_CONSTRUCTORS_IMPL(BigIntBase, HeapObject) @@ -408,8 +404,6 @@ OBJECT_CONSTRUCTORS_IMPL(TemplateObjectDescription, Tuple2) // Cast operations CAST_ACCESSOR(BigInt) -CAST_ACCESSOR(HeapObject) -CAST_ACCESSOR(Object) CAST_ACCESSOR(RegExpMatchInfo) CAST_ACCESSOR(ScopeInfo) CAST_ACCESSOR(TemplateObjectDescription) @@ -635,7 +629,7 @@ void HeapObject::VerifySmiField(int offset) { ReadOnlyRoots HeapObject::GetReadOnlyRoots() const { // TODO(v8:7464): When RO_SPACE is embedded, this will access a global // variable instead. - return ReadOnlyRoots(MemoryChunk::FromHeapObject(*this)->heap()); + return ReadOnlyRoots(GetHeapFromWritableObject(*this)); } Map HeapObject::map() const { return map_word().ToMap(); } @@ -643,7 +637,7 @@ Map HeapObject::map() const { return map_word().ToMap(); } void HeapObject::set_map(Map value) { if (!value.is_null()) { #ifdef VERIFY_HEAP - Heap::FromWritableHeapObject(*this)->VerifyObjectLayoutChange(*this, value); + GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); #endif } set_map_word(MapWord::FromMap(value)); @@ -661,7 +655,7 @@ Map HeapObject::synchronized_map() const { void HeapObject::synchronized_set_map(Map value) { if (!value.is_null()) { #ifdef VERIFY_HEAP - Heap::FromWritableHeapObject(*this)->VerifyObjectLayoutChange(*this, value); + GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); #endif } synchronized_set_map_word(MapWord::FromMap(value)); @@ -677,7 +671,7 @@ void HeapObject::synchronized_set_map(Map value) { void HeapObject::set_map_no_write_barrier(Map value) { if (!value.is_null()) { #ifdef VERIFY_HEAP - Heap::FromWritableHeapObject(*this)->VerifyObjectLayoutChange(*this, value); + GetHeapFromWritableObject(*this)->VerifyObjectLayoutChange(*this, value); #endif } set_map_word(MapWord::FromMap(value)); @@ -806,10 +800,7 @@ void RegExpMatchInfo::SetCapture(int i, int value) { WriteBarrierMode HeapObject::GetWriteBarrierMode( const DisallowHeapAllocation& promise) { - Heap* heap = Heap::FromWritableHeapObject(*this); - if (heap->incremental_marking()->IsMarking()) return UPDATE_WRITE_BARRIER; - if (Heap::InYoungGeneration(*this)) return SKIP_WRITE_BARRIER; - return UPDATE_WRITE_BARRIER; + return GetWriteBarrierModeForObject(*this, &promise); } AllocationAlignment HeapObject::RequiredAlignment(Map map) { @@ -994,7 +985,7 @@ Relocatable::~Relocatable() { // offset of the address in respective MemoryChunk. static inline uint32_t ObjectAddressForHashing(Address object) { uint32_t value = static_cast(object); - return value & MemoryChunk::kAlignmentMask; + return value & kPageAlignmentMask; } static inline Handle MakeEntryPair(Isolate* isolate, uint32_t index, diff --git a/src/objects-printer.cc b/src/objects-printer.cc index e0bba5e5e6..af1f6cdc37 100644 --- a/src/objects-printer.cc +++ b/src/objects-printer.cc @@ -10,6 +10,8 @@ #include "src/bootstrapper.h" #include "src/disasm.h" #include "src/disassembler.h" +#include "src/heap/heap-inl.h" // For InOldSpace. +#include "src/heap/heap-write-barrier-inl.h" // For GetIsolateFromWritableObj. #include "src/interpreter/bytecodes.h" #include "src/objects-inl.h" #include "src/objects/arguments-inl.h" @@ -96,8 +98,9 @@ void HeapObject::PrintHeader(std::ostream& os, const char* id) { // NOLINT os << map()->instance_type(); } os << "]"; - MemoryChunk* chunk = MemoryChunk::FromAddress(ptr()); - if (chunk->owner()->identity() == OLD_SPACE) os << " in OldSpace"; + if (GetHeapFromWritableObject(*this)->InOldSpace(*this)) { + os << " in OldSpace"; + } if (!IsMap()) os << "\n - map: " << Brief(map()); } @@ -2446,7 +2449,7 @@ void Map::MapPrint(std::ostream& os) { // NOLINT Isolate* isolate; // Read-only maps can't have transitions, which is fortunate because we need // the isolate to iterate over the transitions. - if (Isolate::FromWritableHeapObject(*this, &isolate)) { + if (GetIsolateFromWritableObject(*this, &isolate)) { DisallowHeapAllocation no_gc; TransitionsAccessor transitions(isolate, *this, &no_gc); int nof_transitions = transitions.NumberOfTransitions(); diff --git a/src/objects.cc b/src/objects.cc index d67b6be103..6f369b9321 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -38,6 +38,7 @@ #include "src/frames-inl.h" #include "src/function-kind.h" #include "src/globals.h" +#include "src/heap/heap-inl.h" #include "src/ic/ic.h" #include "src/identity-map.h" #include "src/isolate-inl.h" @@ -48,6 +49,7 @@ #include "src/message-template.h" #include "src/microtask-queue.h" #include "src/objects-body-descriptors-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/api-callbacks.h" #include "src/objects/arguments-inl.h" #include "src/objects/bigint.h" @@ -579,6 +581,11 @@ bool Object::BooleanValue(Isolate* isolate) { return true; } +Object Object::ToBoolean(Isolate* isolate) { + if (IsBoolean()) return *this; + return isolate->heap()->ToBoolean(BooleanValue(isolate)); +} + namespace { // TODO(bmeurer): Maybe we should introduce a marker interface Number, @@ -2390,6 +2397,10 @@ void HeapObject::RehashBasedOnMap(Isolate* isolate) { } } +bool HeapObject::IsExternal(Isolate* isolate) const { + return map()->FindRootMap(isolate) == isolate->heap()->external_map(); +} + const char* Representation::Mnemonic() const { switch (kind_) { case kNone: return "v"; @@ -6695,7 +6706,7 @@ MaybeHandle StringTable::LookupTwoCharsStringIfExists( Isolate* isolate, uint16_t c1, uint16_t c2) { - TwoCharHashTableKey key(c1, c2, isolate->heap()->HashSeed()); + TwoCharHashTableKey key(c1, c2, HashSeed(isolate)); Handle string_table = isolate->factory()->string_table(); int entry = string_table->FindEntry(isolate, &key); if (entry == kNotFound) return MaybeHandle(); @@ -7000,7 +7011,7 @@ Address StringTable::LookupStringIfExists_NoAllocate(Isolate* isolate, Heap* heap = isolate->heap(); StringTable table = heap->string_table(); - StringTableNoAllocateKey key(string, heap->HashSeed()); + StringTableNoAllocateKey key(string, HashSeed(isolate)); // String could be an array index. uint32_t hash = string->hash_field(); diff --git a/src/objects.h b/src/objects.h index 4a8e6bf4fc..9dc6ce139c 100644 --- a/src/objects.h +++ b/src/objects.h @@ -652,6 +652,7 @@ class Object { // ECMA-262 9.2. bool BooleanValue(Isolate* isolate); + Object ToBoolean(Isolate* isolate); // ES6 section 7.2.11 Abstract Relational Comparison V8_WARN_UNUSED_RESULT static Maybe Compare( @@ -928,7 +929,8 @@ class Object { void ShortPrint(std::ostream& os) const; // NOLINT - DECL_CAST(Object) + inline static Object cast(Object object) { return object; } + inline static Object unchecked_cast(Object object) { return object; } // Layout description. static const int kHeaderSize = 0; // Object does not take up any space. diff --git a/src/objects/allocation-site-inl.h b/src/objects/allocation-site-inl.h index 8013be073b..ac0a16c944 100644 --- a/src/objects/allocation-site-inl.h +++ b/src/objects/allocation-site-inl.h @@ -7,7 +7,7 @@ #include "src/objects/allocation-site.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects/js-objects-inl.h" // Has to be the last include (doesn't have include guards): diff --git a/src/objects/api-callbacks-inl.h b/src/objects/api-callbacks-inl.h index 8a1b4f0811..7cd08f7052 100644 --- a/src/objects/api-callbacks-inl.h +++ b/src/objects/api-callbacks-inl.h @@ -7,9 +7,10 @@ #include "src/objects/api-callbacks.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/heap/heap-write-barrier.h" #include "src/objects/foreign-inl.h" +#include "src/objects/js-objects-inl.h" #include "src/objects/name.h" #include "src/objects/templates.h" diff --git a/src/objects/bigint.cc b/src/objects/bigint.cc index cb503e3c1d..df3f798f29 100644 --- a/src/objects/bigint.cc +++ b/src/objects/bigint.cc @@ -19,8 +19,14 @@ #include "src/objects/bigint.h" +#include "src/conversions.h" #include "src/double.h" +#include "src/heap/factory.h" +#include "src/heap/heap-write-barrier-inl.h" +#include "src/isolate-inl.h" +#include "src/objects-inl.h" #include "src/objects/heap-number-inl.h" +#include "src/objects/instance-type-inl.h" #include "src/objects/smi.h" namespace v8 { diff --git a/src/objects/cell-inl.h b/src/objects/cell-inl.h index 7e32059fee..c48a82fd31 100644 --- a/src/objects/cell-inl.h +++ b/src/objects/cell-inl.h @@ -7,7 +7,8 @@ #include "src/objects/cell.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/code-inl.h b/src/objects/code-inl.h index 17e7ca8ec9..b2bb4fb673 100644 --- a/src/objects/code-inl.h +++ b/src/objects/code-inl.h @@ -201,10 +201,10 @@ INT_ACCESSORS(Code, handler_table_offset, kHandlerTableOffsetOffset) INT_ACCESSORS(Code, code_comments_offset, kCodeCommentsOffsetOffset) #define CODE_ACCESSORS(name, type, offset) \ ACCESSORS_CHECKED2(Code, name, type, offset, true, \ - !Heap::InYoungGeneration(value)) + !ObjectInYoungGeneration(value)) #define SYNCHRONIZED_CODE_ACCESSORS(name, type, offset) \ SYNCHRONIZED_ACCESSORS_CHECKED2(Code, name, type, offset, true, \ - !Heap::InYoungGeneration(value)) + !ObjectInYoungGeneration(value)) CODE_ACCESSORS(relocation_info, ByteArray, kRelocationInfoOffset) CODE_ACCESSORS(deoptimization_data, FixedArray, kDeoptimizationDataOffset) diff --git a/src/objects/code.cc b/src/objects/code.cc index 50b13775b6..f874855fbe 100644 --- a/src/objects/code.cc +++ b/src/objects/code.cc @@ -4,13 +4,15 @@ #include +#include "src/objects/code.h" + #include "src/assembler-inl.h" #include "src/cpu-features.h" #include "src/deoptimizer.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-decoder.h" #include "src/interpreter/interpreter.h" -#include "src/objects/code.h" +#include "src/objects/allocation-site-inl.h" #include "src/ostreams.h" #include "src/reloc-info.h" #include "src/roots-inl.h" @@ -1046,7 +1048,7 @@ void Code::SetMarkedForDeoptimization(const char* reason) { (deoptimization_data() != GetReadOnlyRoots().empty_fixed_array())) { DeoptimizationData deopt_data = DeoptimizationData::cast(deoptimization_data()); - CodeTracer::Scope scope(GetHeap()->isolate()->GetCodeTracer()); + CodeTracer::Scope scope(GetIsolate()->GetCodeTracer()); PrintF(scope.file(), "[marking dependent code " V8PRIxPTR_FMT " (opt #%d) for deoptimization, reason: %s]\n", diff --git a/src/objects/debug-objects-inl.h b/src/objects/debug-objects-inl.h index 06709f037a..d445174cbc 100644 --- a/src/objects/debug-objects-inl.h +++ b/src/objects/debug-objects-inl.h @@ -7,9 +7,9 @@ #include "src/objects/debug-objects.h" -#include "src/heap/heap-inl.h" -#include "src/heap/heap-write-barrier.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects-inl.h" +#include "src/objects/code-inl.h" #include "src/objects/shared-function-info.h" // Has to be the last include (doesn't have include guards): diff --git a/src/objects/dictionary-inl.h b/src/objects/dictionary-inl.h index 00832838d6..114ad010a3 100644 --- a/src/objects/dictionary-inl.h +++ b/src/objects/dictionary-inl.h @@ -7,6 +7,7 @@ #include "src/objects/dictionary.h" +#include "src/hash-seed-inl.h" #include "src/objects/hash-table-inl.h" #include "src/objects/oddball.h" #include "src/objects/property-cell-inl.h" @@ -137,14 +138,14 @@ bool NumberDictionaryBaseShape::IsMatch(uint32_t key, Object other) { } uint32_t NumberDictionaryBaseShape::Hash(Isolate* isolate, uint32_t key) { - return ComputeSeededHash(key, isolate->heap()->HashSeed()); + return ComputeSeededHash(key, HashSeed(isolate)); } uint32_t NumberDictionaryBaseShape::HashForObject(Isolate* isolate, Object other) { DCHECK(other->IsNumber()); return ComputeSeededHash(static_cast(other->Number()), - isolate->heap()->HashSeed()); + HashSeed(isolate)); } Handle NumberDictionaryBaseShape::AsHandle(Isolate* isolate, diff --git a/src/objects/embedder-data-array-inl.h b/src/objects/embedder-data-array-inl.h index f36310e10f..6519427b7a 100644 --- a/src/objects/embedder-data-array-inl.h +++ b/src/objects/embedder-data-array-inl.h @@ -7,7 +7,7 @@ #include "src/objects/embedder-data-array.h" -//#include "src/objects-inl.h" // Needed for write barriers +#include "src/objects/instance-type-inl.h" #include "src/objects/maybe-object-inl.h" #include "src/objects/slots.h" diff --git a/src/objects/embedder-data-array.cc b/src/objects/embedder-data-array.cc index 665a1fa2f4..c85e0b9f31 100644 --- a/src/objects/embedder-data-array.cc +++ b/src/objects/embedder-data-array.cc @@ -3,6 +3,8 @@ // found in the LICENSE file. #include "src/objects/embedder-data-array.h" + +#include "src/isolate.h" #include "src/objects/embedder-data-array-inl.h" namespace v8 { diff --git a/src/objects/embedder-data-slot-inl.h b/src/objects/embedder-data-slot-inl.h index b136fd288f..1a4d85d778 100644 --- a/src/objects/embedder-data-slot-inl.h +++ b/src/objects/embedder-data-slot-inl.h @@ -5,10 +5,12 @@ #ifndef V8_OBJECTS_EMBEDDER_DATA_SLOT_INL_H_ #define V8_OBJECTS_EMBEDDER_DATA_SLOT_INL_H_ -#include "src/heap/heap-write-barrier-inl.h" -#include "src/objects/embedder-data-array.h" #include "src/objects/embedder-data-slot.h" -#include "src/objects/js-objects.h" + +#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/embedder-data-array.h" +#include "src/objects/js-objects-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/feedback-cell-inl.h b/src/objects/feedback-cell-inl.h index 5d8a5a5780..b3d7d196fc 100644 --- a/src/objects/feedback-cell-inl.h +++ b/src/objects/feedback-cell-inl.h @@ -8,6 +8,8 @@ #include "src/objects/feedback-cell.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/struct-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/fixed-array-inl.h b/src/objects/fixed-array-inl.h index 73a28aea39..c3947bff4d 100644 --- a/src/objects/fixed-array-inl.h +++ b/src/objects/fixed-array-inl.h @@ -7,15 +7,18 @@ #include "src/objects/fixed-array.h" +#include "src/base/tsan.h" #include "src/conversions.h" #include "src/handles-inl.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" #include "src/objects/bigint.h" #include "src/objects/heap-number-inl.h" #include "src/objects/map.h" #include "src/objects/maybe-object-inl.h" #include "src/objects/oddball.h" #include "src/objects/slots.h" +#include "src/roots-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -146,7 +149,7 @@ void FixedArray::NoWriteBarrierSet(FixedArray array, int index, Object value) { DCHECK_NE(array->map(), array->GetReadOnlyRoots().fixed_cow_array_map()); DCHECK_GE(index, 0); DCHECK_LT(index, array->length()); - DCHECK(!Heap::InYoungGeneration(value)); + DCHECK(!ObjectInYoungGeneration(value)); RELAXED_WRITE_FIELD(array, kHeaderSize + index * kTaggedSize, value); } @@ -324,7 +327,7 @@ uint64_t FixedDoubleArray::get_representation(int index) { Handle FixedDoubleArray::get(FixedDoubleArray array, int index, Isolate* isolate) { if (array->is_the_hole(index)) { - return isolate->factory()->the_hole_value(); + return ReadOnlyRoots(isolate).the_hole_value_handle(); } else { return isolate->factory()->NewNumber(array->get_scalar(index)); } diff --git a/src/objects/foreign-inl.h b/src/objects/foreign-inl.h index e601878b33..0ac9f652bb 100644 --- a/src/objects/foreign-inl.h +++ b/src/objects/foreign-inl.h @@ -8,6 +8,7 @@ #include "src/objects/foreign.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/free-space-inl.h b/src/objects/free-space-inl.h index faf01f1ba8..b36c4e154f 100644 --- a/src/objects/free-space-inl.h +++ b/src/objects/free-space-inl.h @@ -7,7 +7,10 @@ #include "src/objects/free-space.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" +#include "src/heap/heap.h" +#include "src/isolate.h" +#include "src/objects-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -24,8 +27,9 @@ int FreeSpace::Size() { return size(); } FreeSpace FreeSpace::next() { #ifdef DEBUG - Heap* heap = Heap::FromWritableHeapObject(*this); - Object free_space_map = heap->isolate()->root(RootIndex::kFreeSpaceMap); + Heap* heap = GetHeapFromWritableObject(*this); + Object free_space_map = + Isolate::FromHeap(heap)->root(RootIndex::kFreeSpaceMap); DCHECK_IMPLIES(!map_slot().contains_value(free_space_map->ptr()), !heap->deserialization_complete() && map_slot().contains_value(kNullAddress)); @@ -36,8 +40,9 @@ FreeSpace FreeSpace::next() { void FreeSpace::set_next(FreeSpace next) { #ifdef DEBUG - Heap* heap = Heap::FromWritableHeapObject(*this); - Object free_space_map = heap->isolate()->root(RootIndex::kFreeSpaceMap); + Heap* heap = GetHeapFromWritableObject(*this); + Object free_space_map = + Isolate::FromHeap(heap)->root(RootIndex::kFreeSpaceMap); DCHECK_IMPLIES(!map_slot().contains_value(free_space_map->ptr()), !heap->deserialization_complete() && map_slot().contains_value(kNullAddress)); @@ -47,7 +52,7 @@ void FreeSpace::set_next(FreeSpace next) { } FreeSpace FreeSpace::cast(HeapObject o) { - SLOW_DCHECK(!Heap::FromWritableHeapObject(o)->deserialization_complete() || + SLOW_DCHECK(!GetHeapFromWritableObject(o)->deserialization_complete() || o->IsFreeSpace()); return bit_cast(o); } diff --git a/src/objects/hash-table-inl.h b/src/objects/hash-table-inl.h index d942c2e3a6..2535286067 100644 --- a/src/objects/hash-table-inl.h +++ b/src/objects/hash-table-inl.h @@ -8,7 +8,9 @@ #include "src/objects/hash-table.h" #include "src/heap/heap.h" +#include "src/objects-inl.h" #include "src/objects/fixed-array-inl.h" +#include "src/objects/heap-object-inl.h" #include "src/roots-inl.h" // Has to be the last include (doesn't have include guards): diff --git a/src/objects/heap-number-inl.h b/src/objects/heap-number-inl.h index 5ebf2ae2b6..ad82296bce 100644 --- a/src/objects/heap-number-inl.h +++ b/src/objects/heap-number-inl.h @@ -7,7 +7,8 @@ #include "src/objects/heap-number.h" -#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/heap-object-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/heap-object-inl.h b/src/objects/heap-object-inl.h index 169b1acd87..fbdcb0f6ec 100644 --- a/src/objects/heap-object-inl.h +++ b/src/objects/heap-object-inl.h @@ -8,6 +8,8 @@ #include "src/objects/heap-object.h" #include "src/heap/heap-write-barrier-inl.h" +// TODO(jkummerow): Get rid of this by moving NROSO::GetIsolate elsewhere. +#include "src/isolate.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -15,6 +17,9 @@ namespace v8 { namespace internal { +OBJECT_CONSTRUCTORS_IMPL(HeapObject, Object) +CAST_ACCESSOR(HeapObject) + HeapObject::HeapObject(Address ptr, AllowInlineSmiStorage allow_smi) : Object(ptr) { SLOW_DCHECK( @@ -32,7 +37,7 @@ Heap* NeverReadOnlySpaceObject::GetHeap(const HeapObject object) { } Isolate* NeverReadOnlySpaceObject::GetIsolate(const HeapObject object) { - return GetHeap(object)->isolate(); + return Isolate::FromHeap(GetHeap(object)); } } // namespace internal diff --git a/src/objects/heap-object.h b/src/objects/heap-object.h index 730bbe2c30..33ee1e2239 100644 --- a/src/objects/heap-object.h +++ b/src/objects/heap-object.h @@ -62,7 +62,7 @@ class HeapObject : public Object { HEAP_OBJECT_TYPE_LIST(IS_TYPE_FUNCTION_DECL) #undef IS_TYPE_FUNCTION_DECL - V8_INLINE bool IsExternal(Isolate* isolate) const; + bool IsExternal(Isolate* isolate) const; // Oddball checks are faster when they are raw pointer comparisons, so the // isolate/read-only roots overloads should be preferred where possible. diff --git a/src/objects/js-array-buffer-inl.h b/src/objects/js-array-buffer-inl.h index a54568f7f2..b1f3ed4ce2 100644 --- a/src/objects/js-array-buffer-inl.h +++ b/src/objects/js-array-buffer-inl.h @@ -7,7 +7,9 @@ #include "src/objects/js-array-buffer.h" -#include "src/objects-inl.h" // Needed for write barriers +#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/js-objects-inl.h" #include "src/wasm/wasm-engine.h" // Has to be the last include (doesn't have include guards): diff --git a/src/objects/js-collection-inl.h b/src/objects/js-collection-inl.h index cae0485f42..79b55fda4a 100644 --- a/src/objects/js-collection-inl.h +++ b/src/objects/js-collection-inl.h @@ -8,7 +8,10 @@ #include "src/objects/js-collection.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/heap-object-inl.h" #include "src/objects/ordered-hash-table-inl.h" +#include "src/roots-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/js-objects-inl.h b/src/objects/js-objects-inl.h index 9a755af84a..10dea9f394 100644 --- a/src/objects/js-objects-inl.h +++ b/src/objects/js-objects-inl.h @@ -433,9 +433,9 @@ Object JSObject::InObjectPropertyAtPut(int index, Object value, void JSObject::InitializeBody(Map map, int start_offset, Object pre_allocated_value, Object filler_value) { DCHECK_IMPLIES(filler_value->IsHeapObject(), - !Heap::InYoungGeneration(filler_value)); + !ObjectInYoungGeneration(filler_value)); DCHECK_IMPLIES(pre_allocated_value->IsHeapObject(), - !Heap::InYoungGeneration(pre_allocated_value)); + !ObjectInYoungGeneration(pre_allocated_value)); int size = map->instance_size(); int offset = start_offset; if (filler_value != pre_allocated_value) { @@ -548,13 +548,13 @@ Code JSFunction::code() const { } void JSFunction::set_code(Code value) { - DCHECK(!Heap::InYoungGeneration(value)); + DCHECK(!ObjectInYoungGeneration(value)); RELAXED_WRITE_FIELD(*this, kCodeOffset, value); MarkingBarrier(*this, RawField(kCodeOffset), value); } void JSFunction::set_code_no_write_barrier(Code value) { - DCHECK(!Heap::InYoungGeneration(value)); + DCHECK(!ObjectInYoungGeneration(value)); RELAXED_WRITE_FIELD(*this, kCodeOffset, value); } @@ -851,8 +851,8 @@ NumberDictionary JSObject::element_dictionary() { void JSReceiver::initialize_properties() { ReadOnlyRoots roots = GetReadOnlyRoots(); - DCHECK(!Heap::InYoungGeneration(roots.empty_fixed_array())); - DCHECK(!Heap::InYoungGeneration(roots.empty_property_dictionary())); + DCHECK(!ObjectInYoungGeneration(roots.empty_fixed_array())); + DCHECK(!ObjectInYoungGeneration(roots.empty_property_dictionary())); if (map()->is_dictionary_map()) { WRITE_FIELD(*this, kPropertiesOrHashOffset, roots.empty_property_dictionary()); @@ -996,7 +996,7 @@ static inline bool ShouldConvertToSlowElements(JSObject object, // TODO(ulan): Check if it works with young large objects. if (*new_capacity <= JSObject::kMaxUncheckedOldFastElementsLength || (*new_capacity <= JSObject::kMaxUncheckedFastElementsLength && - Heap::InYoungGeneration(object))) { + ObjectInYoungGeneration(object))) { return false; } // If the fast-case backing storage takes up much more memory than a diff --git a/src/objects/js-objects.cc b/src/objects/js-objects.cc index 286d734f71..ba4e4b6a26 100644 --- a/src/objects/js-objects.cc +++ b/src/objects/js-objects.cc @@ -13,6 +13,7 @@ #include "src/elements.h" #include "src/field-type.h" #include "src/handles-inl.h" +#include "src/heap/heap-inl.h" #include "src/ic/ic.h" #include "src/isolate.h" #include "src/layout-descriptor.h" @@ -2039,9 +2040,8 @@ void JSObject::EnsureWritableFastElements(Handle object) { DCHECK(object->HasSmiOrObjectElements() || object->HasFastStringWrapperElements()); FixedArray raw_elems = FixedArray::cast(object->elements()); - Heap* heap = object->GetHeap(); - if (raw_elems->map() != ReadOnlyRoots(heap).fixed_cow_array_map()) return; - Isolate* isolate = heap->isolate(); + Isolate* isolate = object->GetIsolate(); + if (raw_elems->map() != ReadOnlyRoots(isolate).fixed_cow_array_map()) return; Handle elems(raw_elems, isolate); Handle writable_elems = isolate->factory()->CopyFixedArrayWithMap( elems, isolate->factory()->fixed_array_map()); diff --git a/src/objects/map-inl.h b/src/objects/map-inl.h index 7113ec290b..955423a806 100644 --- a/src/objects/map-inl.h +++ b/src/objects/map-inl.h @@ -8,7 +8,7 @@ #include "src/objects/map.h" #include "src/field-type.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/layout-descriptor-inl.h" #include "src/objects-inl.h" #include "src/objects/api-callbacks-inl.h" @@ -197,13 +197,14 @@ FixedArrayBase Map::GetInitialElements() const { } else if (has_fast_sloppy_arguments_elements()) { result = GetReadOnlyRoots().empty_sloppy_arguments_elements(); } else if (has_fixed_typed_array_elements()) { - result = GetReadOnlyRoots().EmptyFixedTypedArrayForMap(*this); + result = + GetReadOnlyRoots().EmptyFixedTypedArrayForTypedArray(elements_kind()); } else if (has_dictionary_elements()) { result = GetReadOnlyRoots().empty_slow_element_dictionary(); } else { UNREACHABLE(); } - DCHECK(!Heap::InYoungGeneration(result)); + DCHECK(!ObjectInYoungGeneration(result)); return result; } diff --git a/src/objects/maybe-object-inl.h b/src/objects/maybe-object-inl.h index 8c1023665a..72c328d29b 100644 --- a/src/objects/maybe-object-inl.h +++ b/src/objects/maybe-object-inl.h @@ -10,8 +10,9 @@ #ifdef V8_COMPRESS_POINTERS #include "src/isolate.h" #endif -#include "src/objects-inl.h" +#include "src/objects/heap-object-inl.h" #include "src/objects/slots-inl.h" +#include "src/objects/smi-inl.h" namespace v8 { namespace internal { diff --git a/src/objects/microtask-inl.h b/src/objects/microtask-inl.h index fbd8142ebd..036b227056 100644 --- a/src/objects/microtask-inl.h +++ b/src/objects/microtask-inl.h @@ -7,8 +7,10 @@ #include "src/objects/microtask.h" +#include "src/contexts-inl.h" #include "src/heap/heap-write-barrier-inl.h" #include "src/objects/foreign-inl.h" +#include "src/objects/js-objects-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/name-inl.h b/src/objects/name-inl.h index 293ccf77b4..5e084f76f9 100644 --- a/src/objects/name-inl.h +++ b/src/objects/name-inl.h @@ -7,8 +7,7 @@ #include "src/objects/name.h" -#include "src/heap/heap-inl.h" -#include "src/heap/heap-write-barrier.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects/map-inl.h" // Has to be the last include (doesn't have include guards): @@ -92,7 +91,7 @@ uint32_t Name::Hash() { // Also the string must be writable, because read-only strings will have their // hash values precomputed. return String::cast(*this)->ComputeAndSetHash( - Heap::FromWritableHeapObject(*this)->isolate()); + Isolate::FromHeap(GetHeapFromWritableObject(*this))); } bool Name::IsInterestingSymbol() const { diff --git a/src/objects/object-macros.h b/src/objects/object-macros.h index 39d19cd5ea..3b15d63e09 100644 --- a/src/objects/object-macros.h +++ b/src/objects/object-macros.h @@ -278,21 +278,21 @@ #define WRITE_BARRIER(object, offset, value) \ do { \ - DCHECK_NOT_NULL(Heap::FromWritableHeapObject(object)); \ + DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \ MarkingBarrier(object, (object)->RawField(offset), value); \ GenerationalBarrier(object, (object)->RawField(offset), value); \ } while (false) #define WEAK_WRITE_BARRIER(object, offset, value) \ do { \ - DCHECK_NOT_NULL(Heap::FromWritableHeapObject(object)); \ + DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \ MarkingBarrier(object, (object)->RawMaybeWeakField(offset), value); \ GenerationalBarrier(object, (object)->RawMaybeWeakField(offset), value); \ } while (false) #define CONDITIONAL_WRITE_BARRIER(object, offset, value, mode) \ do { \ - DCHECK_NOT_NULL(Heap::FromWritableHeapObject(object)); \ + DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \ if (mode != SKIP_WRITE_BARRIER) { \ if (mode == UPDATE_WRITE_BARRIER) { \ MarkingBarrier(object, (object)->RawField(offset), value); \ @@ -303,7 +303,7 @@ #define CONDITIONAL_WEAK_WRITE_BARRIER(object, offset, value, mode) \ do { \ - DCHECK_NOT_NULL(Heap::FromWritableHeapObject(object)); \ + DCHECK_NOT_NULL(GetHeapFromWritableObject(object)); \ if (mode != SKIP_WRITE_BARRIER) { \ if (mode == UPDATE_WRITE_BARRIER) { \ MarkingBarrier(object, (object)->RawMaybeWeakField(offset), value); \ diff --git a/src/objects/oddball-inl.h b/src/objects/oddball-inl.h index b799b59d91..fbd5a1b2c6 100644 --- a/src/objects/oddball-inl.h +++ b/src/objects/oddball-inl.h @@ -7,7 +7,10 @@ #include "src/objects/oddball.h" +#include "src/handles.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" +#include "src/objects/string-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" @@ -45,7 +48,7 @@ void Oddball::set_kind(byte value) { // static Handle Oddball::ToNumber(Isolate* isolate, Handle input) { - return handle(input->to_number(), isolate); + return Handle(input->to_number(), isolate); } bool HeapObject::IsBoolean() const { diff --git a/src/objects/ordered-hash-table-inl.h b/src/objects/ordered-hash-table-inl.h index 277c033994..95ddf06132 100644 --- a/src/objects/ordered-hash-table-inl.h +++ b/src/objects/ordered-hash-table-inl.h @@ -8,6 +8,7 @@ #include "src/objects/ordered-hash-table.h" #include "src/heap/heap.h" +#include "src/objects-inl.h" #include "src/objects/fixed-array-inl.h" // Has to be the last include (doesn't have include guards): diff --git a/src/objects/ordered-hash-table.cc b/src/objects/ordered-hash-table.cc index d4cd6fbe0c..3581b344d4 100644 --- a/src/objects/ordered-hash-table.cc +++ b/src/objects/ordered-hash-table.cc @@ -4,6 +4,7 @@ #include "src/objects/ordered-hash-table.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/js-collection-inl.h" diff --git a/src/objects/property-array-inl.h b/src/objects/property-array-inl.h index b9785c563f..fa3f4ccde2 100644 --- a/src/objects/property-array-inl.h +++ b/src/objects/property-array-inl.h @@ -8,6 +8,7 @@ #include "src/objects/property-array.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" #include "src/objects/heap-object-inl.h" #include "src/objects/smi-inl.h" diff --git a/src/objects/property-cell-inl.h b/src/objects/property-cell-inl.h index 6b8e396cd4..d6600234ad 100644 --- a/src/objects/property-cell-inl.h +++ b/src/objects/property-cell-inl.h @@ -7,8 +7,8 @@ #include "src/objects/property-cell.h" -#include "src/heap/heap-inl.h" -#include "src/objects/code.h" +#include "src/heap/heap-write-barrier-inl.h" +#include "src/objects/code-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/prototype-info-inl.h b/src/objects/prototype-info-inl.h index 7bb8ed109c..ddcb50fe90 100644 --- a/src/objects/prototype-info-inl.h +++ b/src/objects/prototype-info-inl.h @@ -8,8 +8,11 @@ #include "src/objects/prototype-info.h" #include "src/heap/heap-write-barrier-inl.h" -#include "src/objects/map.h" +#include "src/objects-inl.h" +#include "src/objects/fixed-array-inl.h" +#include "src/objects/map-inl.h" #include "src/objects/maybe-object.h" +#include "src/objects/struct-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/shared-function-info-inl.h b/src/objects/shared-function-info-inl.h index a547f567ae..1e57379c2e 100644 --- a/src/objects/shared-function-info-inl.h +++ b/src/objects/shared-function-info-inl.h @@ -10,7 +10,7 @@ #include "src/ast/ast.h" #include "src/feedback-vector-inl.h" #include "src/handles-inl.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects/debug-objects-inl.h" #include "src/objects/scope-info.h" #include "src/objects/templates.h" @@ -611,7 +611,7 @@ void SharedFunctionInfo::ClearPreparseData() { // Trim off the pre-parsed scope data from the uncompiled data by swapping the // map, leaving only an uncompiled data without pre-parsed scope. DisallowHeapAllocation no_gc; - Heap* heap = Heap::FromWritableHeapObject(data); + Heap* heap = GetHeapFromWritableObject(data); // Swap the map. heap->NotifyObjectLayoutChange(data, UncompiledDataWithPreparseData::kSize, diff --git a/src/objects/stack-frame-info-inl.h b/src/objects/stack-frame-info-inl.h index 4aafaed9e7..4bcf3a5672 100644 --- a/src/objects/stack-frame-info-inl.h +++ b/src/objects/stack-frame-info-inl.h @@ -8,7 +8,9 @@ #include "src/objects/stack-frame-info.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" #include "src/objects/frame-array-inl.h" +#include "src/objects/struct-inl.h" // Has to be the last include (doesn't have include guards): #include "src/objects/object-macros.h" diff --git a/src/objects/string-inl.h b/src/objects/string-inl.h index f86ef2185e..6292584540 100644 --- a/src/objects/string-inl.h +++ b/src/objects/string-inl.h @@ -9,6 +9,7 @@ #include "src/conversions-inl.h" #include "src/handles-inl.h" +#include "src/hash-seed-inl.h" #include "src/heap/factory.h" #include "src/objects/name-inl.h" #include "src/objects/smi-inl.h" @@ -243,7 +244,7 @@ class SeqOneByteSubStringKey : public StringTableKey { // We have to set the hash later. DisallowHeapAllocation no_gc; uint32_t hash = StringHasher::HashSequentialString( - string->GetChars(no_gc) + from, length, isolate->heap()->HashSeed()); + string->GetChars(no_gc) + from, length, HashSeed(isolate)); set_hash_field(hash); DCHECK_LE(0, length_); @@ -603,8 +604,9 @@ void ExternalOneByteString::SetResource( Isolate* isolate, const ExternalOneByteString::Resource* resource) { set_resource(resource); size_t new_payload = resource == nullptr ? 0 : resource->length(); - if (new_payload > 0) + if (new_payload > 0) { isolate->heap()->UpdateExternalString(*this, 0, new_payload); + } } void ExternalOneByteString::set_resource( @@ -638,8 +640,9 @@ void ExternalTwoByteString::SetResource( Isolate* isolate, const ExternalTwoByteString::Resource* resource) { set_resource(resource); size_t new_payload = resource == nullptr ? 0 : resource->length() * 2; - if (new_payload > 0) + if (new_payload > 0) { isolate->heap()->UpdateExternalString(*this, 0, new_payload); + } } void ExternalTwoByteString::set_resource( diff --git a/src/objects/string.cc b/src/objects/string.cc index d950604fea..f93f71c6fa 100644 --- a/src/objects/string.cc +++ b/src/objects/string.cc @@ -7,10 +7,11 @@ #include "src/char-predicates.h" #include "src/conversions.h" #include "src/handles-inl.h" -#include "src/handles.h" +#include "src/heap/heap-inl.h" // For LooksValid implementation. #include "src/objects/map.h" #include "src/objects/oddball.h" #include "src/objects/string-comparator.h" +#include "src/objects/string-inl.h" #include "src/ostreams.h" #include "src/string-builder-inl.h" #include "src/string-hasher.h" @@ -39,7 +40,7 @@ Handle String::SlowFlatten(Isolate* isolate, Handle cons, DCHECK(AllowHeapAllocation::IsAllowed()); int length = cons->length(); - PretenureFlag tenure = Heap::InYoungGeneration(*cons) ? pretenure : TENURED; + PretenureFlag tenure = ObjectInYoungGeneration(*cons) ? pretenure : TENURED; Handle result; if (cons->IsOneByteRepresentation()) { Handle flat = isolate->factory() @@ -84,7 +85,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) { Isolate* isolate; // Read-only strings cannot be made external, since that would mutate the // string. - if (!Isolate::FromWritableHeapObject(*this, &isolate)) return false; + if (!GetIsolateFromWritableObject(*this, &isolate)) return false; Heap* heap = isolate->heap(); bool is_one_byte = this->IsOneByteRepresentation(); bool is_internalized = this->IsInternalizedString(); @@ -170,7 +171,7 @@ bool String::MakeExternal(v8::String::ExternalOneByteStringResource* resource) { Isolate* isolate; // Read-only strings cannot be made external, since that would mutate the // string. - if (!Isolate::FromWritableHeapObject(*this, &isolate)) return false; + if (!GetIsolateFromWritableObject(*this, &isolate)) return false; Heap* heap = isolate->heap(); bool is_internalized = this->IsInternalizedString(); bool has_pointers = StringShape(*this).IsIndirect(); @@ -223,7 +224,7 @@ bool String::SupportsExternalization() { Isolate* isolate; // RO_SPACE strings cannot be externalized. - if (!Isolate::FromWritableHeapObject(*this, &isolate)) { + if (!GetIsolateFromWritableObject(*this, &isolate)) { return false; } @@ -1243,8 +1244,7 @@ uint32_t String::ComputeAndSetHash(Isolate* isolate) { DCHECK(!HasHashCode()); // Store the hash code in the object. - uint32_t field = - IteratingStringHasher::Hash(*this, isolate->heap()->HashSeed()); + uint32_t field = IteratingStringHasher::Hash(*this, HashSeed(isolate)); set_hash_field(field); // Check the hash code is there. @@ -1301,8 +1301,8 @@ Handle SeqString::Truncate(Handle string, int new_length) { int delta = old_size - new_size; Address start_of_string = string->address(); - DCHECK_OBJECT_ALIGNED(start_of_string); - DCHECK_OBJECT_ALIGNED(start_of_string + new_size); + DCHECK(IsAligned(start_of_string, kObjectAlignment)); + DCHECK(IsAligned(start_of_string + new_size, kObjectAlignment)); Heap* heap = Heap::FromWritableHeapObject(*string); // Sizes are pointer size aligned, so that we can use filler objects diff --git a/src/objects/struct-inl.h b/src/objects/struct-inl.h index 4045ee2d1d..9502698058 100644 --- a/src/objects/struct-inl.h +++ b/src/objects/struct-inl.h @@ -8,6 +8,7 @@ #include "src/objects/struct.h" #include "src/heap/heap-write-barrier-inl.h" +#include "src/objects-inl.h" #include "src/objects/oddball.h" #include "src/roots-inl.h" diff --git a/src/objects/templates-inl.h b/src/objects/templates-inl.h index eccf63a599..90b1f05c6c 100644 --- a/src/objects/templates-inl.h +++ b/src/objects/templates-inl.h @@ -7,7 +7,7 @@ #include "src/objects/templates.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects/oddball.h" #include "src/objects/shared-function-info-inl.h" diff --git a/src/parsing/parse-info.cc b/src/parsing/parse-info.cc index 72a45d5728..098482c573 100644 --- a/src/parsing/parse-info.cc +++ b/src/parsing/parse-info.cc @@ -10,6 +10,7 @@ #include "src/base/template-utils.h" #include "src/compiler-dispatcher/compiler-dispatcher.h" #include "src/counters.h" +#include "src/hash-seed-inl.h" #include "src/heap/heap-inl.h" #include "src/log.h" #include "src/objects-inl.h" @@ -43,7 +44,7 @@ ParseInfo::ParseInfo(AccountingAllocator* zone_allocator) ParseInfo::ParseInfo(Isolate* isolate, AccountingAllocator* zone_allocator) : ParseInfo(zone_allocator) { - set_hash_seed(isolate->heap()->HashSeed()); + set_hash_seed(HashSeed(isolate)); set_stack_limit(isolate->stack_guard()->real_climit()); set_runtime_call_stats(isolate->counters()->runtime_call_stats()); set_logger(isolate->logger()); diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc index f302f1f919..3001b170f9 100644 --- a/src/parsing/parser.cc +++ b/src/parsing/parser.cc @@ -27,6 +27,7 @@ #include "src/runtime/runtime.h" #include "src/string-stream.h" #include "src/tracing/trace-event.h" +#include "src/zone/zone-list-inl.h" namespace v8 { namespace internal { diff --git a/src/parsing/parsing.cc b/src/parsing/parsing.cc index 7ff080b2f9..eb17d17793 100644 --- a/src/parsing/parsing.cc +++ b/src/parsing/parsing.cc @@ -12,6 +12,7 @@ #include "src/parsing/parser.h" #include "src/parsing/scanner-character-streams.h" #include "src/vm-state-inl.h" +#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 namespace v8 { namespace internal { diff --git a/src/parsing/preparse-data.cc b/src/parsing/preparse-data.cc index b834bbfadc..a38d280ce4 100644 --- a/src/parsing/preparse-data.cc +++ b/src/parsing/preparse-data.cc @@ -14,6 +14,7 @@ #include "src/parsing/parser.h" #include "src/parsing/preparse-data-impl.h" #include "src/parsing/preparser.h" +#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 namespace v8 { namespace internal { diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc index ec6792eb70..2c25c7adaf 100644 --- a/src/parsing/preparser.cc +++ b/src/parsing/preparser.cc @@ -14,6 +14,7 @@ #include "src/parsing/preparser.h" #include "src/unicode.h" #include "src/utils.h" +#include "src/zone/zone-list-inl.h" namespace v8 { namespace internal { diff --git a/src/parsing/rewriter.cc b/src/parsing/rewriter.cc index 5ba7b3ba51..5ab1937c3c 100644 --- a/src/parsing/rewriter.cc +++ b/src/parsing/rewriter.cc @@ -9,6 +9,7 @@ #include "src/objects-inl.h" #include "src/parsing/parse-info.h" #include "src/parsing/parser.h" +#include "src/zone/zone-list-inl.h" namespace v8 { namespace internal { diff --git a/src/ppc/macro-assembler-ppc.cc b/src/ppc/macro-assembler-ppc.cc index deb3ed8543..0209efcacb 100644 --- a/src/ppc/macro-assembler-ppc.cc +++ b/src/ppc/macro-assembler-ppc.cc @@ -16,6 +16,7 @@ #include "src/debug/debug.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/register-configuration.h" #include "src/runtime/runtime.h" diff --git a/src/profiler/allocation-tracker.cc b/src/profiler/allocation-tracker.cc index d01060543d..4f22d1b472 100644 --- a/src/profiler/allocation-tracker.cc +++ b/src/profiler/allocation-tracker.cc @@ -208,7 +208,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) { // while we are capturing stack trace. heap->CreateFillerObjectAt(addr, size, ClearRecordedSlots::kNo); - Isolate* isolate = heap->isolate(); + Isolate* isolate = Isolate::FromHeap(heap); int length = 0; JavaScriptFrameIterator it(isolate); while (!it.done() && length < kMaxAllocationTraceLength) { diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc index c9169422f4..5e85a08b6d 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc @@ -14,6 +14,7 @@ #include "src/layout-descriptor.h" #include "src/objects-body-descriptors.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/api-callbacks.h" #include "src/objects/cell-inl.h" #include "src/objects/feedback-cell-inl.h" @@ -788,8 +789,9 @@ void V8HeapExplorer::ExtractJSObjectReferences(HeapEntry* entry, ExtractPropertyReferences(js_obj, entry); ExtractElementReferences(js_obj, entry); ExtractInternalReferences(js_obj, entry); - PrototypeIterator iter(heap_->isolate(), js_obj); - ReadOnlyRoots roots(heap_); + Isolate* isolate = Isolate::FromHeap(heap_); + PrototypeIterator iter(isolate, js_obj); + ReadOnlyRoots roots(isolate); SetPropertyReference(entry, roots.proto_string(), iter.GetCurrent()); if (obj->IsJSBoundFunction()) { JSBoundFunction js_fun = JSBoundFunction::cast(obj); @@ -810,7 +812,7 @@ void V8HeapExplorer::ExtractJSObjectReferences(HeapEntry* entry, JSFunction js_fun = JSFunction::cast(js_obj); if (js_fun->has_prototype_slot()) { Object proto_or_map = js_fun->prototype_or_initial_map(); - if (!proto_or_map->IsTheHole(heap_->isolate())) { + if (!proto_or_map->IsTheHole(isolate)) { if (!proto_or_map->IsMap()) { SetPropertyReference(entry, roots.prototype_string(), proto_or_map, nullptr, @@ -1694,7 +1696,7 @@ void V8HeapExplorer::SetGcSubrootReference(Root root, const char* description, const char* V8HeapExplorer::GetStrongGcSubrootName(Object object) { if (strong_gc_subroot_names_.empty()) { - Isolate* isolate = heap_->isolate(); + Isolate* isolate = Isolate::FromHeap(heap_); for (RootIndex root_index = RootIndex::kFirstStrongOrReadOnlyRoot; root_index <= RootIndex::kLastStrongOrReadOnlyRoot; ++root_index) { const char* name = RootsTable::name(root_index); @@ -1739,7 +1741,7 @@ class GlobalObjectsEnumerator : public RootVisitor { // Modifies heap. Must not be run during heap traversal. void V8HeapExplorer::TagGlobalObjects() { - Isolate* isolate = heap_->isolate(); + Isolate* isolate = Isolate::FromHeap(heap_); HandleScope scope(isolate); GlobalObjectsEnumerator enumerator; isolate->global_handles()->IterateAllRoots(&enumerator); @@ -1864,13 +1866,13 @@ HeapEntry* EmbedderGraphEntriesAllocator::AllocateEntry(HeapThing ptr) { NativeObjectsExplorer::NativeObjectsExplorer( HeapSnapshot* snapshot, SnapshottingProgressReportingInterface* progress) - : isolate_(snapshot->profiler()->heap_object_map()->heap()->isolate()), + : isolate_( + Isolate::FromHeap(snapshot->profiler()->heap_object_map()->heap())), snapshot_(snapshot), names_(snapshot_->profiler()->names()), embedder_graph_entries_allocator_( new EmbedderGraphEntriesAllocator(snapshot)) {} - HeapEntry* NativeObjectsExplorer::EntryForEmbedderGraphNode( EmbedderGraphImpl::Node* node) { EmbedderGraphImpl::Node* wrapper = node->WrapperNode(); @@ -1973,7 +1975,7 @@ bool HeapSnapshotGenerator::GenerateSnapshot() { heap_->PreciseCollectAllGarbage(Heap::kNoGCFlags, GarbageCollectionReason::kHeapProfiler); - NullContextScope null_context_scope(heap_->isolate()); + NullContextScope null_context_scope(Isolate::FromHeap(heap_)); #ifdef VERIFY_HEAP Heap* debug_heap = heap_; diff --git a/src/profiler/sampling-heap-profiler.cc b/src/profiler/sampling-heap-profiler.cc index 3e158544fd..659ed25c00 100644 --- a/src/profiler/sampling-heap-profiler.cc +++ b/src/profiler/sampling-heap-profiler.cc @@ -53,14 +53,14 @@ v8::AllocationProfile::Allocation SamplingHeapProfiler::ScaleSample( SamplingHeapProfiler::SamplingHeapProfiler( Heap* heap, StringsStorage* names, uint64_t rate, int stack_depth, v8::HeapProfiler::SamplingFlags flags) - : isolate_(heap->isolate()), + : isolate_(Isolate::FromHeap(heap)), heap_(heap), new_space_observer_(new SamplingAllocationObserver( heap_, static_cast(rate), rate, this, - heap->isolate()->random_number_generator())), + isolate_->random_number_generator())), other_spaces_observer_(new SamplingAllocationObserver( heap_, static_cast(rate), rate, this, - heap->isolate()->random_number_generator())), + isolate_->random_number_generator())), names_(names), profile_root_(nullptr, "(root)", v8::UnboundScript::kNoScriptId, 0, next_node_id()), diff --git a/src/profiler/tick-sample.cc b/src/profiler/tick-sample.cc index 9435c8c927..449712345a 100644 --- a/src/profiler/tick-sample.cc +++ b/src/profiler/tick-sample.cc @@ -8,6 +8,7 @@ #include "src/asan.h" #include "src/counters.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryAllocator::code_range. #include "src/msan.h" #include "src/simulator.h" #include "src/vm-state-inl.h" diff --git a/src/property-descriptor.cc b/src/property-descriptor.cc index 4947bfb99f..9feab5d4bf 100644 --- a/src/property-descriptor.cc +++ b/src/property-descriptor.cc @@ -6,6 +6,7 @@ #include "src/bootstrapper.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/lookup.h" #include "src/objects-inl.h" diff --git a/src/regexp/jsregexp.cc b/src/regexp/jsregexp.cc index 1b02b23d59..9e0d6109e4 100644 --- a/src/regexp/jsregexp.cc +++ b/src/regexp/jsregexp.cc @@ -13,6 +13,7 @@ #include "src/elements.h" #include "src/execution.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/isolate-inl.h" #include "src/message-template.h" #include "src/ostreams.h" @@ -28,6 +29,7 @@ #include "src/string-search.h" #include "src/unicode-decoder.h" #include "src/unicode-inl.h" +#include "src/zone/zone-list-inl.h" #ifdef V8_INTL_SUPPORT #include "unicode/uniset.h" @@ -6754,7 +6756,7 @@ RegExpEngine::CompilationResult RegExpEngine::Compile( bool RegExpEngine::TooMuchRegExpCode(Isolate* isolate, Handle pattern) { Heap* heap = isolate->heap(); bool too_much = pattern->length() > RegExpImpl::kRegExpTooLargeToOptimize; - if (heap->isolate()->total_regexp_code_generated() > + if (isolate->total_regexp_code_generated() > RegExpImpl::kRegExpCompiledLimit && heap->CommittedMemoryExecutable() > RegExpImpl::kRegExpExecutableMemoryLimit) { diff --git a/src/regexp/regexp-parser.cc b/src/regexp/regexp-parser.cc index 614af95b97..97be9fa27b 100644 --- a/src/regexp/regexp-parser.cc +++ b/src/regexp/regexp-parser.cc @@ -14,6 +14,7 @@ #include "src/regexp/jsregexp.h" #include "src/regexp/property-sequences.h" #include "src/utils.h" +#include "src/zone/zone-list-inl.h" #ifdef V8_INTL_SUPPORT #include "unicode/uniset.h" diff --git a/src/roots-inl.h b/src/roots-inl.h index f5bf098875..cae3d37a39 100644 --- a/src/roots-inl.h +++ b/src/roots-inl.h @@ -9,15 +9,18 @@ #include "src/feedback-vector.h" #include "src/handles.h" -#include "src/heap/heap-inl.h" +#include "src/isolate.h" #include "src/objects/api-callbacks.h" -#include "src/objects/descriptor-array-inl.h" +#include "src/objects/descriptor-array.h" #include "src/objects/heap-number.h" #include "src/objects/literal-objects.h" #include "src/objects/map.h" +#include "src/objects/oddball.h" +#include "src/objects/property-array.h" #include "src/objects/property-cell.h" #include "src/objects/scope-info.h" #include "src/objects/slots.h" +#include "src/objects/string.h" namespace v8 { namespace internal { @@ -54,17 +57,24 @@ bool RootsTable::IsRootHandle(Handle handle, RootIndex* index) const { } ReadOnlyRoots::ReadOnlyRoots(Heap* heap) - : roots_table_(heap->isolate()->roots_table()) {} + : roots_table_(Isolate::FromHeap(heap)->roots_table()) {} ReadOnlyRoots::ReadOnlyRoots(Isolate* isolate) : roots_table_(isolate->roots_table()) {} -#define ROOT_ACCESSOR(Type, name, CamelName) \ - Type ReadOnlyRoots::name() const { \ - return Type::cast(Object(roots_table_[RootIndex::k##CamelName])); \ - } \ - Handle ReadOnlyRoots::name##_handle() const { \ - return Handle(&roots_table_[RootIndex::k##CamelName]); \ +// We use unchecked_cast below because we trust our read-only roots to +// have the right type, and to avoid the heavy #includes that would be +// required for checked casts. + +#define ROOT_ACCESSOR(Type, name, CamelName) \ + Type ReadOnlyRoots::name() const { \ + DCHECK(CheckType(RootIndex::k##CamelName)); \ + return Type::unchecked_cast( \ + Object(roots_table_[RootIndex::k##CamelName])); \ + } \ + Handle ReadOnlyRoots::name##_handle() const { \ + DCHECK(CheckType(RootIndex::k##CamelName)); \ + return Handle(&roots_table_[RootIndex::k##CamelName]); \ } READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) @@ -72,18 +82,22 @@ READ_ONLY_ROOT_LIST(ROOT_ACCESSOR) Map ReadOnlyRoots::MapForFixedTypedArray(ExternalArrayType array_type) { RootIndex root_index = RootsTable::RootIndexForFixedTypedArray(array_type); - return Map::cast(Object(roots_table_[root_index])); + DCHECK(CheckType(root_index)); + return Map::unchecked_cast(Object(roots_table_[root_index])); } Map ReadOnlyRoots::MapForFixedTypedArray(ElementsKind elements_kind) { RootIndex root_index = RootsTable::RootIndexForFixedTypedArray(elements_kind); - return Map::cast(Object(roots_table_[root_index])); + DCHECK(CheckType(root_index)); + return Map::unchecked_cast(Object(roots_table_[root_index])); } -FixedTypedArrayBase ReadOnlyRoots::EmptyFixedTypedArrayForMap(const Map map) { +FixedTypedArrayBase ReadOnlyRoots::EmptyFixedTypedArrayForTypedArray( + ElementsKind elements_kind) { RootIndex root_index = - RootsTable::RootIndexForEmptyFixedTypedArray(map->elements_kind()); - return FixedTypedArrayBase::cast(Object(roots_table_[root_index])); + RootsTable::RootIndexForEmptyFixedTypedArray(elements_kind); + DCHECK(CheckType(root_index)); + return FixedTypedArrayBase::unchecked_cast(Object(roots_table_[root_index])); } } // namespace internal diff --git a/src/roots.cc b/src/roots.cc index 8a0ed69895..65aadbca17 100644 --- a/src/roots.cc +++ b/src/roots.cc @@ -5,6 +5,7 @@ #include "src/roots.h" #include "src/elements-kind.h" +#include "src/objects-inl.h" #include "src/visitors.h" namespace v8 { @@ -65,5 +66,24 @@ void ReadOnlyRoots::Iterate(RootVisitor* visitor) { visitor->Synchronize(VisitorSynchronization::kReadOnlyRootList); } +#ifdef DEBUG + +bool ReadOnlyRoots::CheckType(RootIndex index) const { + Object root(roots_table_[index]); + switch (index) { +#define CHECKTYPE(Type, name, CamelName) \ + case RootIndex::k##CamelName: \ + return root->Is##Type(); + READ_ONLY_ROOT_LIST(CHECKTYPE) +#undef CHECKTYPE + + default: + UNREACHABLE(); + return false; + } +} + +#endif // DEBUG + } // namespace internal } // namespace v8 diff --git a/src/roots.h b/src/roots.h index c261bec776..86efdb232a 100644 --- a/src/roots.h +++ b/src/roots.h @@ -524,13 +524,18 @@ class ReadOnlyRoots { V8_INLINE Map MapForFixedTypedArray(ExternalArrayType array_type); V8_INLINE Map MapForFixedTypedArray(ElementsKind elements_kind); - V8_INLINE FixedTypedArrayBase EmptyFixedTypedArrayForMap(const Map map); + V8_INLINE FixedTypedArrayBase + EmptyFixedTypedArrayForTypedArray(ElementsKind elements_kind); // Iterate over all the read-only roots. This is not necessary for garbage // collection and is usually only performed as part of (de)serialization or // heap verification. void Iterate(RootVisitor* visitor); +#ifdef DEBUG + V8_EXPORT_PRIVATE bool CheckType(RootIndex index) const; +#endif + private: RootsTable& roots_table_; }; diff --git a/src/runtime/runtime-array.cc b/src/runtime/runtime-array.cc index 067f023d54..febecaf892 100644 --- a/src/runtime/runtime-array.cc +++ b/src/runtime/runtime-array.cc @@ -8,8 +8,11 @@ #include "src/debug/debug.h" #include "src/elements.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. +#include "src/heap/heap-write-barrier-inl.h" #include "src/isolate-inl.h" #include "src/keys.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/arguments-inl.h" #include "src/objects/hash-table-inl.h" #include "src/objects/js-array-inl.h" @@ -208,7 +211,7 @@ Object RemoveArrayHoles(Isolate* isolate, Handle receiver, JSObject::GetElementsTransitionMap(object, HOLEY_ELEMENTS); PretenureFlag tenure = - Heap::InYoungGeneration(*object) ? NOT_TENURED : TENURED; + ObjectInYoungGeneration(*object) ? NOT_TENURED : TENURED; Handle fast_elements = isolate->factory()->NewFixedArray(dict->NumberOfElements(), tenure); dict->CopyValuesTo(*fast_elements); diff --git a/src/runtime/runtime-collections.cc b/src/runtime/runtime-collections.cc index 2f03bb8532..42f6af5f4f 100644 --- a/src/runtime/runtime-collections.cc +++ b/src/runtime/runtime-collections.cc @@ -6,6 +6,7 @@ #include "src/conversions-inl.h" #include "src/counters.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/objects/hash-table-inl.h" #include "src/objects/js-collection-inl.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-debug.cc b/src/runtime/runtime-debug.cc index 98aa3b98e7..7213832cfe 100644 --- a/src/runtime/runtime-debug.cc +++ b/src/runtime/runtime-debug.cc @@ -15,6 +15,7 @@ #include "src/debug/liveedit.h" #include "src/frames-inl.h" #include "src/globals.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/interpreter/bytecode-array-accessor.h" #include "src/interpreter/bytecodes.h" #include "src/interpreter/interpreter.h" diff --git a/src/runtime/runtime-forin.cc b/src/runtime/runtime-forin.cc index b0bb297bfe..56580e91da 100644 --- a/src/runtime/runtime-forin.cc +++ b/src/runtime/runtime-forin.cc @@ -8,6 +8,7 @@ #include "src/counters.h" #include "src/elements.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/keys.h" #include "src/objects-inl.h" diff --git a/src/runtime/runtime-function.cc b/src/runtime/runtime-function.cc index 1edbd3d5cb..ee813bff11 100644 --- a/src/runtime/runtime-function.cc +++ b/src/runtime/runtime-function.cc @@ -6,6 +6,7 @@ #include "src/arguments-inl.h" #include "src/compiler.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-numbers.cc b/src/runtime/runtime-numbers.cc index 59f15a62bd..edceef20a5 100644 --- a/src/runtime/runtime-numbers.cc +++ b/src/runtime/runtime-numbers.cc @@ -6,6 +6,7 @@ #include "src/base/bits.h" #include "src/bootstrapper.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index 8e52e5803c..680863620c 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -6,6 +6,7 @@ #include "src/bootstrapper.h" #include "src/counters.h" #include "src/debug/debug.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/message-template.h" #include "src/objects/hash-table-inl.h" diff --git a/src/runtime/runtime-operators.cc b/src/runtime/runtime-operators.cc index 1ce7fffd18..cc932f2b41 100644 --- a/src/runtime/runtime-operators.cc +++ b/src/runtime/runtime-operators.cc @@ -4,6 +4,7 @@ #include "src/arguments.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-proxy.cc b/src/runtime/runtime-proxy.cc index 88abb22774..11544cd34b 100644 --- a/src/runtime/runtime-proxy.cc +++ b/src/runtime/runtime-proxy.cc @@ -8,6 +8,7 @@ #include "src/counters.h" #include "src/elements.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/objects-inl.h" diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc index f472da7478..aa4c900838 100644 --- a/src/runtime/runtime-regexp.cc +++ b/src/runtime/runtime-regexp.cc @@ -7,11 +7,11 @@ #include "src/arguments-inl.h" #include "src/conversions-inl.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/message-template.h" #include "src/objects/js-array-inl.h" #include "src/regexp/jsregexp-inl.h" -#include "src/regexp/jsregexp.h" #include "src/regexp/regexp-utils.h" #include "src/runtime/runtime-utils.h" #include "src/string-builder-inl.h" diff --git a/src/runtime/runtime-scopes.cc b/src/runtime/runtime-scopes.cc index 85d8ce90c9..6783387b70 100644 --- a/src/runtime/runtime-scopes.cc +++ b/src/runtime/runtime-scopes.cc @@ -11,6 +11,7 @@ #include "src/counters.h" #include "src/deoptimizer.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/message-template.h" #include "src/objects/heap-object-inl.h" diff --git a/src/runtime/runtime-strings.cc b/src/runtime/runtime-strings.cc index 623c687ee9..136ba7f759 100644 --- a/src/runtime/runtime-strings.cc +++ b/src/runtime/runtime-strings.cc @@ -5,6 +5,7 @@ #include "src/arguments-inl.h" #include "src/conversions.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/objects/js-array-inl.h" #include "src/objects/slots.h" diff --git a/src/runtime/runtime-symbol.cc b/src/runtime/runtime-symbol.cc index 8cd48505d2..b47794938a 100644 --- a/src/runtime/runtime-symbol.cc +++ b/src/runtime/runtime-symbol.cc @@ -4,6 +4,7 @@ #include "src/arguments-inl.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. #include "src/isolate-inl.h" #include "src/objects-inl.h" #include "src/runtime/runtime-utils.h" diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 07e946d86e..b367044269 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -16,6 +16,8 @@ #include "src/counters.h" #include "src/deoptimizer.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For ToBoolean. TODO(jkummerow): Drop. +#include "src/heap/heap-write-barrier-inl.h" #include "src/ic/stub-cache.h" #include "src/isolate-inl.h" #include "src/objects/heap-object-inl.h" @@ -805,7 +807,7 @@ RUNTIME_FUNCTION(Runtime_InNewSpace) { SealHandleScope shs(isolate); DCHECK_EQ(1, args.length()); CONVERT_ARG_CHECKED(Object, obj, 0); - return isolate->heap()->ToBoolean(Heap::InYoungGeneration(obj)); + return isolate->heap()->ToBoolean(ObjectInYoungGeneration(obj)); } RUNTIME_FUNCTION(Runtime_IsAsmWasmCode) { diff --git a/src/s390/macro-assembler-s390.cc b/src/s390/macro-assembler-s390.cc index 4f31b39b18..d42aa79aac 100644 --- a/src/s390/macro-assembler-s390.cc +++ b/src/s390/macro-assembler-s390.cc @@ -16,6 +16,7 @@ #include "src/debug/debug.h" #include "src/external-reference-table.h" #include "src/frames-inl.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/objects/smi.h" #include "src/register-configuration.h" diff --git a/src/snapshot/code-serializer.cc b/src/snapshot/code-serializer.cc index cba32ac2d4..df728fcfc9 100644 --- a/src/snapshot/code-serializer.cc +++ b/src/snapshot/code-serializer.cc @@ -6,6 +6,7 @@ #include "src/counters.h" #include "src/debug/debug.h" +#include "src/heap/heap-inl.h" #include "src/log.h" #include "src/macro-assembler.h" #include "src/objects-inl.h" diff --git a/src/snapshot/deserializer.cc b/src/snapshot/deserializer.cc index 69e5dfd6f2..f6dcdbe385 100644 --- a/src/snapshot/deserializer.cc +++ b/src/snapshot/deserializer.cc @@ -5,6 +5,7 @@ #include "src/snapshot/deserializer.h" #include "src/assembler-inl.h" +#include "src/heap/heap-inl.h" #include "src/heap/heap-write-barrier-inl.h" #include "src/interpreter/interpreter.h" #include "src/isolate.h" diff --git a/src/snapshot/object-deserializer.cc b/src/snapshot/object-deserializer.cc index bcf5026e36..44b7088380 100644 --- a/src/snapshot/object-deserializer.cc +++ b/src/snapshot/object-deserializer.cc @@ -5,8 +5,10 @@ #include "src/snapshot/object-deserializer.h" #include "src/assembler-inl.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects.h" +#include "src/objects/allocation-site-inl.h" #include "src/objects/slots.h" #include "src/snapshot/code-serializer.h" diff --git a/src/snapshot/partial-deserializer.cc b/src/snapshot/partial-deserializer.cc index 769b46e468..4dd25980e8 100644 --- a/src/snapshot/partial-deserializer.cc +++ b/src/snapshot/partial-deserializer.cc @@ -5,6 +5,7 @@ #include "src/snapshot/partial-deserializer.h" #include "src/api-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects/slots.h" #include "src/snapshot/snapshot.h" diff --git a/src/snapshot/read-only-serializer.cc b/src/snapshot/read-only-serializer.cc index a6348aa2cd..7fa38f78ea 100644 --- a/src/snapshot/read-only-serializer.cc +++ b/src/snapshot/read-only-serializer.cc @@ -7,6 +7,7 @@ #include "src/api.h" #include "src/code-tracer.h" #include "src/global-handles.h" +#include "src/heap/heap-inl.h" // For InReadOnlySpace. #include "src/objects-inl.h" #include "src/objects/slots.h" #include "src/snapshot/startup-serializer.h" @@ -25,7 +26,7 @@ ReadOnlySerializer::~ReadOnlySerializer() { } void ReadOnlySerializer::SerializeObject(HeapObject obj) { - CHECK(isolate()->heap()->read_only_space()->Contains(obj)); + CHECK(isolate()->heap()->InReadOnlySpace(obj)); CHECK_IMPLIES(obj->IsString(), obj->IsInternalizedString()); if (SerializeHotObject(obj)) return; @@ -79,7 +80,7 @@ bool ReadOnlySerializer::MustBeDeferred(HeapObject object) { bool ReadOnlySerializer::SerializeUsingReadOnlyObjectCache( SnapshotByteSink* sink, HeapObject obj) { - if (!isolate()->heap()->read_only_space()->Contains(obj)) return false; + if (!isolate()->heap()->InReadOnlySpace(obj)) return false; // Get the cache index and serialize it into the read-only snapshot if // necessary. diff --git a/src/snapshot/roots-serializer.cc b/src/snapshot/roots-serializer.cc index de95a4fa85..e634c45eff 100644 --- a/src/snapshot/roots-serializer.cc +++ b/src/snapshot/roots-serializer.cc @@ -40,7 +40,7 @@ void RootsSerializer::Synchronize(VisitorSynchronization::SyncTag tag) { void RootsSerializer::VisitRootPointers(Root root, const char* description, FullObjectSlot start, FullObjectSlot end) { - RootsTable& roots_table = isolate()->heap()->roots_table(); + RootsTable& roots_table = isolate()->roots_table(); if (start == roots_table.begin() + static_cast(first_root_to_be_serialized_)) { // Serializing the root list needs special handling: diff --git a/src/snapshot/serializer.cc b/src/snapshot/serializer.cc index 48d7aad1d6..e5b371ef28 100644 --- a/src/snapshot/serializer.cc +++ b/src/snapshot/serializer.cc @@ -5,7 +5,7 @@ #include "src/snapshot/serializer.h" #include "src/assembler-inl.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" // For Space::identity(). #include "src/interpreter/interpreter.h" #include "src/objects/code.h" #include "src/objects/js-array-buffer-inl.h" diff --git a/src/snapshot/startup-serializer.cc b/src/snapshot/startup-serializer.cc index 6cea9e1936..79b6fe5b72 100644 --- a/src/snapshot/startup-serializer.cc +++ b/src/snapshot/startup-serializer.cc @@ -9,6 +9,7 @@ #include "src/contexts.h" #include "src/deoptimizer.h" #include "src/global-handles.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/objects/foreign-inl.h" #include "src/objects/slots.h" @@ -110,7 +111,7 @@ void StartupSerializer::SerializeObject(HeapObject obj) { CheckRehashability(obj); // Object has not yet been serialized. Serialize it here. - DCHECK(!isolate()->heap()->read_only_space()->Contains(obj)); + DCHECK(!isolate()->heap()->InReadOnlySpace(obj)); ObjectSerializer object_serializer(this, obj, &sink_); object_serializer.Serialize(); } diff --git a/src/string-builder.cc b/src/string-builder.cc index 57571a11a1..75b899c87c 100644 --- a/src/string-builder.cc +++ b/src/string-builder.cc @@ -166,7 +166,7 @@ ReplacementStringBuilder::ReplacementStringBuilder(Heap* heap, Handle subject, int estimated_part_count) : heap_(heap), - array_builder_(heap->isolate(), estimated_part_count), + array_builder_(Isolate::FromHeap(heap), estimated_part_count), subject_(subject), character_count_(0), is_one_byte_(subject->IsOneByteRepresentation()) { @@ -176,7 +176,7 @@ ReplacementStringBuilder::ReplacementStringBuilder(Heap* heap, } void ReplacementStringBuilder::EnsureCapacity(int elements) { - array_builder_.EnsureCapacity(heap_->isolate(), elements); + array_builder_.EnsureCapacity(Isolate::FromHeap(heap_), elements); } void ReplacementStringBuilder::AddString(Handle string) { @@ -190,7 +190,7 @@ void ReplacementStringBuilder::AddString(Handle string) { } MaybeHandle ReplacementStringBuilder::ToString() { - Isolate* isolate = heap_->isolate(); + Isolate* isolate = Isolate::FromHeap(heap_); if (array_builder_.length() == 0) { return isolate->factory()->empty_string(); } diff --git a/src/wasm/module-compiler.cc b/src/wasm/module-compiler.cc index 4f456925b0..29eba9f10e 100644 --- a/src/wasm/module-compiler.cc +++ b/src/wasm/module-compiler.cc @@ -12,6 +12,7 @@ #include "src/base/utils/random-number-generator.h" #include "src/compiler/wasm-compiler.h" #include "src/counters.h" +#include "src/heap/heap-inl.h" // For CodeSpaceMemoryModificationScope. #include "src/identity-map.h" #include "src/property-descriptor.h" #include "src/task-utils.h" diff --git a/src/wasm/module-instantiate.cc b/src/wasm/module-instantiate.cc index a8b15270ee..0caeeb2af2 100644 --- a/src/wasm/module-instantiate.cc +++ b/src/wasm/module-instantiate.cc @@ -4,6 +4,7 @@ #include "src/wasm/module-instantiate.h" #include "src/asmjs/asm-js.h" +#include "src/heap/heap-inl.h" // For CodeSpaceMemoryModificationScope. #include "src/property-descriptor.h" #include "src/utils.h" #include "src/wasm/js-to-wasm-wrapper-cache-inl.h" diff --git a/src/wasm/wasm-objects-inl.h b/src/wasm/wasm-objects-inl.h index a4e632e931..9a25995203 100644 --- a/src/wasm/wasm-objects-inl.h +++ b/src/wasm/wasm-objects-inl.h @@ -8,12 +8,15 @@ #include "src/wasm/wasm-objects.h" #include "src/contexts-inl.h" -#include "src/heap/heap-inl.h" +#include "src/heap/heap-write-barrier-inl.h" #include "src/objects/foreign-inl.h" #include "src/objects/heap-number-inl.h" #include "src/objects/js-array-buffer-inl.h" +#include "src/objects/js-objects-inl.h" #include "src/objects/managed.h" #include "src/objects/oddball-inl.h" +#include "src/objects/script-inl.h" +#include "src/roots.h" #include "src/v8memory.h" #include "src/wasm/wasm-code-manager.h" #include "src/wasm/wasm-module.h" diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc index 4b47bba09f..76f0c5e771 100644 --- a/src/x64/macro-assembler-x64.cc +++ b/src/x64/macro-assembler-x64.cc @@ -15,6 +15,7 @@ #include "src/external-reference-table.h" #include "src/frames-inl.h" #include "src/globals.h" +#include "src/heap/heap-inl.h" // For MemoryChunk. #include "src/macro-assembler.h" #include "src/objects-inl.h" #include "src/objects/smi.h" diff --git a/test/cctest/heap/test-alloc.cc b/test/cctest/heap/test-alloc.cc index 89bb25b56c..7a377d2b9b 100644 --- a/test/cctest/heap/test-alloc.cc +++ b/test/cctest/heap/test-alloc.cc @@ -30,6 +30,7 @@ #include "src/accessors.h" #include "src/api-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/objects/api-callbacks.h" #include "src/property.h" diff --git a/test/cctest/heap/test-compaction.cc b/test/cctest/heap/test-compaction.cc index 20ad68695b..eea4a6eb43 100644 --- a/test/cctest/heap/test-compaction.cc +++ b/test/cctest/heap/test-compaction.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/heap/mark-compact.h" #include "src/isolate.h" #include "src/objects-inl.h" diff --git a/test/cctest/heap/test-embedder-tracing.cc b/test/cctest/heap/test-embedder-tracing.cc index 58951dc7e0..096c73ae03 100644 --- a/test/cctest/heap/test-embedder-tracing.cc +++ b/test/cctest/heap/test-embedder-tracing.cc @@ -7,6 +7,7 @@ #include "include/v8.h" #include "src/api-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/objects/module.h" #include "src/objects/script.h" diff --git a/test/cctest/heap/test-external-string-tracker.cc b/test/cctest/heap/test-external-string-tracker.cc index 8b8c313c42..bcc00764de 100644 --- a/test/cctest/heap/test-external-string-tracker.cc +++ b/test/cctest/heap/test-external-string-tracker.cc @@ -4,6 +4,7 @@ #include "src/api-inl.h" #include "src/api.h" +#include "src/heap/heap-inl.h" #include "src/heap/spaces.h" #include "src/isolate.h" #include "src/objects-inl.h" diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 67bb255af1..1e8f65f983 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -37,8 +37,10 @@ #include "src/execution.h" #include "src/field-type.h" #include "src/global-handles.h" +#include "src/hash-seed-inl.h" #include "src/heap/factory.h" #include "src/heap/gc-tracer.h" +#include "src/heap/heap-inl.h" #include "src/heap/incremental-marking.h" #include "src/heap/mark-compact.h" #include "src/heap/memory-reducer.h" @@ -6315,7 +6317,7 @@ UNINITIALIZED_TEST(ReinitializeStringHashSeed) { { v8::Isolate::Scope isolate_scope(isolate); CHECK_EQ(static_cast(1337 * i), - reinterpret_cast(isolate)->heap()->HashSeed()); + HashSeed(reinterpret_cast(isolate))); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); CHECK(!context.IsEmpty()); diff --git a/test/cctest/heap/test-weak-references.cc b/test/cctest/heap/test-weak-references.cc index a9d737904a..bcf8622d31 100644 --- a/test/cctest/heap/test-weak-references.cc +++ b/test/cctest/heap/test-weak-references.cc @@ -5,6 +5,7 @@ #include "src/api-inl.h" #include "src/assembler-inl.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects/smi.h" #include "test/cctest/cctest.h" diff --git a/test/cctest/interpreter/interpreter-tester.cc b/test/cctest/interpreter/interpreter-tester.cc index a361a98a52..c66c1a279b 100644 --- a/test/cctest/interpreter/interpreter-tester.cc +++ b/test/cctest/interpreter/interpreter-tester.cc @@ -5,6 +5,7 @@ #include "test/cctest/interpreter/interpreter-tester.h" #include "src/api-inl.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" namespace v8 { diff --git a/test/cctest/interpreter/test-interpreter-intrinsics.cc b/test/cctest/interpreter/test-interpreter-intrinsics.cc index bfc42aa540..becc46ab9c 100644 --- a/test/cctest/interpreter/test-interpreter-intrinsics.cc +++ b/test/cctest/interpreter/test-interpreter-intrinsics.cc @@ -5,6 +5,7 @@ #include "src/v8.h" #include "src/api-inl.h" +#include "src/heap/heap-inl.h" #include "src/interpreter/interpreter-intrinsics.h" #include "src/objects-inl.h" #include "test/cctest/interpreter/interpreter-tester.h" diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc index 021af5a414..fab903ce4e 100644 --- a/test/cctest/interpreter/test-interpreter.cc +++ b/test/cctest/interpreter/test-interpreter.cc @@ -11,6 +11,8 @@ #include "src/compiler.h" #include "src/execution.h" #include "src/handles.h" +#include "src/hash-seed-inl.h" +#include "src/heap/heap-inl.h" #include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-flags.h" @@ -162,7 +164,7 @@ TEST(InterpreterLoadLiteral) { // Heap numbers. { AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); BytecodeArrayBuilder builder(zone, 1, 0); @@ -180,7 +182,7 @@ TEST(InterpreterLoadLiteral) { // Strings. { AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); BytecodeArrayBuilder builder(zone, 1, 0); @@ -486,7 +488,7 @@ TEST(InterpreterStringAdd) { Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); struct TestCase { const AstRawString* lhs; @@ -579,7 +581,7 @@ TEST(InterpreterParameter8) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); BytecodeArrayBuilder builder(zone, 8, 0, &feedback_spec); @@ -632,7 +634,7 @@ TEST(InterpreterBinaryOpTypeFeedback) { i::Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); struct BinaryOpExpectation { Token::Value op; @@ -766,7 +768,7 @@ TEST(InterpreterBinaryOpSmiTypeFeedback) { i::Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); struct BinaryOpExpectation { Token::Value op; @@ -1131,7 +1133,7 @@ TEST(InterpreterLoadNamedProperty) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); FeedbackSlot slot = feedback_spec.AddLoadICSlot(); @@ -1183,7 +1185,7 @@ TEST(InterpreterLoadKeyedProperty) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); FeedbackSlot slot = feedback_spec.AddKeyedLoadICSlot(); @@ -1225,7 +1227,7 @@ TEST(InterpreterStoreNamedProperty) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); FeedbackSlot slot = feedback_spec.AddStoreICSlot(LanguageMode::kStrict); @@ -1288,7 +1290,7 @@ TEST(InterpreterStoreKeyedProperty) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); FeedbackSlot slot = feedback_spec.AddKeyedStoreICSlot(LanguageMode::kSloppy); @@ -1340,7 +1342,7 @@ TEST(InterpreterCall) { Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); FeedbackSlot slot = feedback_spec.AddLoadICSlot(); @@ -1652,7 +1654,7 @@ TEST(InterpreterJumpConstantWith16BitOperand) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); BytecodeArrayBuilder builder(zone, 1, 257, &feedback_spec); @@ -1713,7 +1715,7 @@ TEST(InterpreterJumpWith32BitOperand) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); BytecodeArrayBuilder builder(zone, 1, 1); Register reg(0); BytecodeLabel done; @@ -1852,7 +1854,7 @@ TEST(InterpreterHeapNumberComparisons) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); BytecodeArrayBuilder builder(zone, 1, 1, &feedback_spec); @@ -1899,7 +1901,7 @@ TEST(InterpreterBigIntComparisons) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); BytecodeArrayBuilder builder(zone, 1, 1, &feedback_spec); @@ -1944,7 +1946,7 @@ TEST(InterpreterStringComparisons) { for (size_t i = 0; i < arraysize(inputs); i++) { for (size_t j = 0; j < arraysize(inputs); j++) { AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); CanonicalHandleScope canonical(isolate); const char* lhs = inputs[i].c_str(); @@ -2027,7 +2029,7 @@ TEST(InterpreterMixedComparisons) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); FeedbackVectorSpec feedback_spec(zone); BytecodeArrayBuilder builder(zone, 1, 0, &feedback_spec); @@ -2265,7 +2267,7 @@ TEST(InterpreterTestIn) { Zone* zone = handles.main_zone(); Factory* factory = isolate->factory(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); // Allocate an array Handle array = factory->NewJSArray(0, i::ElementsKind::PACKED_SMI_ELEMENTS); @@ -2323,7 +2325,7 @@ TEST(InterpreterUnaryNotNonBoolean) { Isolate* isolate = handles.main_isolate(); Zone* zone = handles.main_zone(); AstValueFactory ast_factory(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); std::pair object_type_tuples[] = { std::make_pair(LiteralForTest(LiteralForTest::kUndefined), true), diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4a461ccdef..feb20ee558 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -49,6 +49,7 @@ #include "src/feedback-vector.h" #include "src/futex-emulation.h" #include "src/global-handles.h" +#include "src/heap/heap-inl.h" #include "src/heap/incremental-marking.h" #include "src/heap/local-allocator.h" #include "src/lookup.h" diff --git a/test/cctest/test-code-stub-assembler.cc b/test/cctest/test-code-stub-assembler.cc index fdbf09d3aa..e7f592d1c5 100644 --- a/test/cctest/test-code-stub-assembler.cc +++ b/test/cctest/test-code-stub-assembler.cc @@ -14,6 +14,7 @@ #include "src/code-stub-assembler.h" #include "src/compiler/node.h" #include "src/debug/debug.h" +#include "src/hash-seed-inl.h" #include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" @@ -350,7 +351,7 @@ TEST(ComputeIntegerHash) { Handle key(Smi::FromInt(k), isolate); Handle result = ft.Call(key).ToHandleChecked(); - uint32_t hash = ComputeSeededHash(k, isolate->heap()->HashSeed()); + uint32_t hash = ComputeSeededHash(k, HashSeed(isolate)); Smi expected = Smi::FromInt(hash); CHECK_EQ(expected, Smi::cast(*result)); } diff --git a/test/cctest/test-compiler.cc b/test/cctest/test-compiler.cc index 83380b29c6..b107c87717 100644 --- a/test/cctest/test-compiler.cc +++ b/test/cctest/test-compiler.cc @@ -35,8 +35,10 @@ #include "src/compiler.h" #include "src/disasm.h" #include "src/heap/factory.h" +#include "src/heap/spaces.h" #include "src/interpreter/interpreter.h" #include "src/objects-inl.h" +#include "src/objects/allocation-site-inl.h" #include "test/cctest/cctest.h" namespace v8 { diff --git a/test/cctest/test-global-handles.cc b/test/cctest/test-global-handles.cc index f4f992ccf3..b81007f40e 100644 --- a/test/cctest/test-global-handles.cc +++ b/test/cctest/test-global-handles.cc @@ -28,6 +28,7 @@ #include "src/api-inl.h" #include "src/global-handles.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "test/cctest/cctest.h" diff --git a/test/cctest/test-heap-profiler.cc b/test/cctest/test-heap-profiler.cc index 1bf252364f..5e61199e86 100644 --- a/test/cctest/test-heap-profiler.cc +++ b/test/cctest/test-heap-profiler.cc @@ -40,6 +40,7 @@ #include "src/base/optional.h" #include "src/collector.h" #include "src/debug/debug.h" +#include "src/heap/heap-inl.h" #include "src/objects-inl.h" #include "src/profiler/allocation-tracker.h" #include "src/profiler/heap-profiler.h" diff --git a/test/cctest/test-mementos.cc b/test/cctest/test-mementos.cc index aa2b23c413..78b1e6a981 100644 --- a/test/cctest/test-mementos.cc +++ b/test/cctest/test-mementos.cc @@ -26,7 +26,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "src/heap/factory.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "test/cctest/cctest.h" diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc index 2725bf4d59..e4120b2777 100644 --- a/test/cctest/test-parsing.cc +++ b/test/cctest/test-parsing.cc @@ -50,6 +50,7 @@ #include "src/parsing/rewriter.h" #include "src/parsing/scanner-character-streams.h" #include "src/parsing/token.h" +#include "src/zone/zone-list-inl.h" // crbug.com/v8/8816 #include "test/cctest/cctest.h" #include "test/cctest/scope-test-helper.h" @@ -613,9 +614,8 @@ TEST(ScanHTMLEndComments) { i::Scanner scanner(stream.get(), false); scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory(&zone, - i_isolate->ast_string_constants(), - i_isolate->heap()->HashSeed()); + i::AstValueFactory ast_value_factory( + &zone, i_isolate->ast_string_constants(), HashSeed(i_isolate)); i::PendingCompilationErrorHandler pending_error_handler; i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, @@ -632,9 +632,8 @@ TEST(ScanHTMLEndComments) { i::Scanner scanner(stream.get(), false); scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory(&zone, - i_isolate->ast_string_constants(), - i_isolate->heap()->HashSeed()); + i::AstValueFactory ast_value_factory( + &zone, i_isolate->ast_string_constants(), HashSeed(i_isolate)); i::PendingCompilationErrorHandler pending_error_handler; i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, @@ -705,9 +704,8 @@ TEST(StandAlonePreParser) { scanner.Initialize(); i::Zone zone(i_isolate->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory(&zone, - i_isolate->ast_string_constants(), - i_isolate->heap()->HashSeed()); + i::AstValueFactory ast_value_factory( + &zone, i_isolate->ast_string_constants(), HashSeed(i_isolate)); i::PendingCompilationErrorHandler pending_error_handler; i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, @@ -725,8 +723,8 @@ TEST(StandAlonePreParserNoNatives) { v8::V8::Initialize(); i::Isolate* isolate = CcTest::i_isolate(); - CcTest::i_isolate()->stack_guard()->SetStackLimit( - i::GetCurrentStackPosition() - 128 * 1024); + isolate->stack_guard()->SetStackLimit(i::GetCurrentStackPosition() - + 128 * 1024); const char* programs[] = {"%ArgleBargle(glop);", "var x = %_IsSmi(42);", nullptr}; @@ -738,10 +736,9 @@ TEST(StandAlonePreParserNoNatives) { scanner.Initialize(); // Preparser defaults to disallowing natives syntax. - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory( - &zone, CcTest::i_isolate()->ast_string_constants(), - CcTest::i_isolate()->heap()->HashSeed()); + i::Zone zone(isolate->allocator(), ZONE_NAME); + i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(), + HashSeed(isolate)); i::PendingCompilationErrorHandler pending_error_handler; i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, @@ -772,15 +769,14 @@ TEST(RegressChromium62639) { auto stream = i::ScannerStream::ForTesting(program); i::Scanner scanner(stream.get(), false); scanner.Initialize(); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory( - &zone, CcTest::i_isolate()->ast_string_constants(), - CcTest::i_isolate()->heap()->HashSeed()); + i::Zone zone(isolate->allocator(), ZONE_NAME); + i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(), + HashSeed(isolate)); i::PendingCompilationErrorHandler pending_error_handler; - i::PreParser preparser( - &zone, &scanner, CcTest::i_isolate()->stack_guard()->real_climit(), - &ast_value_factory, &pending_error_handler, - isolate->counters()->runtime_call_stats(), isolate->logger()); + i::PreParser preparser(&zone, &scanner, isolate->stack_guard()->real_climit(), + &ast_value_factory, &pending_error_handler, + isolate->counters()->runtime_call_stats(), + isolate->logger()); i::PreParser::PreParseResult result = preparser.PreParseProgram(); // Even in the case of a syntax error, kPreParseSuccess is returned. CHECK_EQ(i::PreParser::kPreParseSuccess, result); @@ -807,10 +803,9 @@ TEST(PreParseOverflow) { i::Scanner scanner(stream.get(), false); scanner.Initialize(); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory( - &zone, CcTest::i_isolate()->ast_string_constants(), - CcTest::i_isolate()->heap()->HashSeed()); + i::Zone zone(isolate->allocator(), ZONE_NAME); + i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(), + HashSeed(isolate)); i::PendingCompilationErrorHandler pending_error_handler; i::PreParser preparser( &zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, @@ -911,7 +906,7 @@ void TestScanRegExp(const char* re_source, const char* expected) { i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); i::AstValueFactory ast_value_factory( &zone, CcTest::i_isolate()->ast_string_constants(), - CcTest::i_isolate()->heap()->HashSeed()); + HashSeed(CcTest::i_isolate())); const i::AstRawString* current_symbol = scanner.CurrentSymbol(&ast_value_factory); ast_value_factory.Internalize(CcTest::i_isolate()); @@ -1595,10 +1590,9 @@ void TestParserSyncWithFlags(i::Handle source, std::unique_ptr stream( i::ScannerStream::For(isolate, source)); i::Scanner scanner(stream.get(), is_module); - i::Zone zone(CcTest::i_isolate()->allocator(), ZONE_NAME); - i::AstValueFactory ast_value_factory( - &zone, CcTest::i_isolate()->ast_string_constants(), - CcTest::i_isolate()->heap()->HashSeed()); + i::Zone zone(isolate->allocator(), ZONE_NAME); + i::AstValueFactory ast_value_factory(&zone, isolate->ast_string_constants(), + HashSeed(isolate)); i::PreParser preparser(&zone, &scanner, stack_limit, &ast_value_factory, &pending_error_handler, isolate->counters()->runtime_call_stats(), @@ -3235,7 +3229,7 @@ TEST(SerializationOfMaybeAssignmentFlag) { i::Handle f = i::Handle::cast(o); i::Context context = f->context(); i::AstValueFactory avf(&zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); const i::AstRawString* name = avf.GetOneByteString("result"); avf.Internalize(isolate); i::Handle str = name->string(); @@ -3285,7 +3279,7 @@ TEST(IfArgumentsArrayAccessedThenParametersMaybeAssigned) { i::Handle f = i::Handle::cast(o); i::Context context = f->context(); i::AstValueFactory avf(&zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); const i::AstRawString* name_x = avf.GetOneByteString("x"); avf.Internalize(isolate); @@ -4200,7 +4194,7 @@ namespace { i::Scope* DeserializeFunctionScope(i::Isolate* isolate, i::Zone* zone, i::Handle m, const char* name) { i::AstValueFactory avf(zone, isolate->ast_string_constants(), - isolate->heap()->HashSeed()); + HashSeed(isolate)); i::Handle f = i::Handle::cast( i::JSReceiver::GetProperty(isolate, m, name).ToHandleChecked()); i::DeclarationScope* script_scope = diff --git a/test/cctest/test-regexp.cc b/test/cctest/test-regexp.cc index fd06f08477..49dcc49c3e 100644 --- a/test/cctest/test-regexp.cc +++ b/test/cctest/test-regexp.cc @@ -46,6 +46,7 @@ #include "src/string-stream.h" #include "src/unicode-inl.h" #include "src/v8.h" +#include "src/zone/zone-list-inl.h" #if V8_TARGET_ARCH_ARM #include "src/regexp/arm/regexp-macro-assembler-arm.h" diff --git a/test/cctest/test-roots.cc b/test/cctest/test-roots.cc index 98283723d4..a0ad1f06c6 100644 --- a/test/cctest/test-roots.cc +++ b/test/cctest/test-roots.cc @@ -2,7 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" +#include "src/objects/cell.h" +#include "src/objects/feedback-cell.h" +#include "src/objects/script.h" #include "src/roots-inl.h" #include "test/cctest/cctest.h" diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 4b77ed317d..06a9b8b540 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -37,6 +37,8 @@ #include "src/compilation-cache.h" #include "src/compiler.h" #include "src/debug/debug.h" +#include "src/hash-seed-inl.h" +#include "src/heap/heap-inl.h" #include "src/heap/spaces.h" #include "src/interpreter/interpreter.h" #include "src/macro-assembler-inl.h" @@ -3681,7 +3683,7 @@ UNINITIALIZED_TEST(ReinitializeHashSeedNotRehashable) { { // Check that no rehashing has been performed. CHECK_EQ(static_cast(42), - reinterpret_cast(isolate)->heap()->HashSeed()); + HashSeed(reinterpret_cast(isolate))); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); @@ -3746,7 +3748,7 @@ UNINITIALIZED_TEST(ReinitializeHashSeedRehashable) { { // Check that rehashing has been performed. CHECK_EQ(static_cast(1337), - reinterpret_cast(isolate)->heap()->HashSeed()); + HashSeed(reinterpret_cast(isolate))); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); v8::Local context = v8::Context::New(isolate); diff --git a/test/cctest/test-strings.cc b/test/cctest/test-strings.cc index 6970bc422d..0871992ec6 100644 --- a/test/cctest/test-strings.cc +++ b/test/cctest/test-strings.cc @@ -37,6 +37,7 @@ #include "src/api-inl.h" #include "src/base/platform/elapsed-timer.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/messages.h" #include "src/objects-inl.h" #include "src/unicode-decoder.h" diff --git a/test/cctest/test-unboxed-doubles.cc b/test/cctest/test-unboxed-doubles.cc index 1c8b1d5a63..c202140f42 100644 --- a/test/cctest/test-unboxed-doubles.cc +++ b/test/cctest/test-unboxed-doubles.cc @@ -15,6 +15,7 @@ #include "src/field-type.h" #include "src/global-handles.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/heap/incremental-marking.h" #include "src/heap/spaces.h" #include "src/ic/ic.h" diff --git a/test/cctest/test-unwinder.cc b/test/cctest/test-unwinder.cc index 26b7c99b2f..63ce17d57c 100644 --- a/test/cctest/test-unwinder.cc +++ b/test/cctest/test-unwinder.cc @@ -6,6 +6,7 @@ #include "src/api-inl.h" #include "src/builtins/builtins.h" +#include "src/heap/spaces.h" #include "src/isolate.h" #include "src/objects/code-inl.h" #include "test/cctest/cctest.h" diff --git a/test/cctest/test-weakmaps.cc b/test/cctest/test-weakmaps.cc index e8ed0f4179..4ef3766473 100644 --- a/test/cctest/test-weakmaps.cc +++ b/test/cctest/test-weakmaps.cc @@ -29,6 +29,7 @@ #include "src/global-handles.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" diff --git a/test/cctest/test-weaksets.cc b/test/cctest/test-weaksets.cc index e1c89bd174..36c9e339b8 100644 --- a/test/cctest/test-weaksets.cc +++ b/test/cctest/test-weaksets.cc @@ -29,6 +29,7 @@ #include "src/global-handles.h" #include "src/heap/factory.h" +#include "src/heap/heap-inl.h" #include "src/isolate.h" #include "src/objects-inl.h" #include "src/objects/hash-table-inl.h" diff --git a/test/cctest/wasm/wasm-run-utils.cc b/test/cctest/wasm/wasm-run-utils.cc index 431348f54f..8cf9fe84b6 100644 --- a/test/cctest/wasm/wasm-run-utils.cc +++ b/test/cctest/wasm/wasm-run-utils.cc @@ -6,6 +6,7 @@ #include "src/assembler-inl.h" #include "src/code-tracer.h" +#include "src/heap/heap-inl.h" #include "src/wasm/graph-builder-interface.h" #include "src/wasm/wasm-import-wrapper-cache-inl.h" #include "src/wasm/wasm-memory.h" diff --git a/test/mkgrokdump/mkgrokdump.cc b/test/mkgrokdump/mkgrokdump.cc index 60b46656e4..8c30c653cd 100644 --- a/test/mkgrokdump/mkgrokdump.cc +++ b/test/mkgrokdump/mkgrokdump.cc @@ -8,7 +8,7 @@ #include "include/v8.h" #include "src/frames.h" -#include "src/heap/heap.h" +#include "src/heap/heap-inl.h" #include "src/heap/spaces.h" #include "src/isolate.h" #include "src/objects-inl.h" diff --git a/test/unittests/background-compile-task-unittest.cc b/test/unittests/background-compile-task-unittest.cc index 5bb6b68285..2577a974fe 100644 --- a/test/unittests/background-compile-task-unittest.cc +++ b/test/unittests/background-compile-task-unittest.cc @@ -18,6 +18,7 @@ #include "src/parsing/parser.h" #include "src/parsing/preparse-data.h" #include "src/v8.h" +#include "src/zone/zone-list-inl.h" #include "test/unittests/test-helpers.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc b/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc index f6fa65edc2..1bad7fed10 100644 --- a/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc +++ b/test/unittests/compiler-dispatcher/compiler-dispatcher-unittest.cc @@ -20,6 +20,7 @@ #include "src/parsing/parse-info.h" #include "src/parsing/parsing.h" #include "src/v8.h" +#include "src/zone/zone-list-inl.h" #include "test/unittests/test-helpers.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/test/unittests/heap/heap-unittest.cc b/test/unittests/heap/heap-unittest.cc index 53954d8178..2f588a843e 100644 --- a/test/unittests/heap/heap-unittest.cc +++ b/test/unittests/heap/heap-unittest.cc @@ -6,13 +6,10 @@ #include #include -#include "src/objects.h" -#include "src/objects-inl.h" - -#include "src/handles.h" #include "src/handles-inl.h" - #include "src/heap/heap.h" +#include "src/heap/spaces-inl.h" +#include "src/objects-inl.h" #include "test/unittests/test-utils.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/test/unittests/interpreter/bytecode-array-builder-unittest.cc b/test/unittests/interpreter/bytecode-array-builder-unittest.cc index 1a0c583f62..3df844c4bd 100644 --- a/test/unittests/interpreter/bytecode-array-builder-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-builder-unittest.cc @@ -7,6 +7,7 @@ #include "src/v8.h" #include "src/ast/scopes.h" +#include "src/hash-seed-inl.h" #include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-jump-table.h" @@ -34,7 +35,7 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { BytecodeArrayBuilder builder(zone(), 1, 131, &feedback_spec); Factory* factory = isolate()->factory(); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); DeclarationScope scope(zone(), &ast_factory); CHECK_EQ(builder.locals_count(), 131); @@ -534,7 +535,7 @@ TEST_F(BytecodeArrayBuilderTest, Parameters) { TEST_F(BytecodeArrayBuilderTest, Constants) { BytecodeArrayBuilder builder(zone(), 1, 0); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_1 = 3.14; double heap_num_2 = 5.2; diff --git a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc index ec70605dde..0e72e2ec8d 100644 --- a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/hash-seed-inl.h" #include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-iterator.h" #include "src/objects-inl.h" @@ -27,7 +28,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); diff --git a/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc b/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc index 2e2d92628f..6ec19fb726 100644 --- a/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-random-iterator-unittest.cc @@ -4,6 +4,7 @@ #include "src/v8.h" +#include "src/hash-seed-inl.h" #include "src/interpreter/bytecode-array-builder.h" #include "src/interpreter/bytecode-array-random-iterator.h" #include "src/objects-inl.h" @@ -27,7 +28,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidBeforeStart) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -81,7 +82,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, InvalidAfterEnd) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -135,7 +136,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesFirst) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -193,7 +194,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, AccessesLast) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -252,7 +253,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, RandomAccessValid) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -437,7 +438,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArray) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); @@ -716,7 +717,7 @@ TEST_F(BytecodeArrayRandomIteratorTest, IteratesBytecodeArrayBackwards) { FeedbackVectorSpec feedback_spec(zone()); BytecodeArrayBuilder builder(zone(), 3, 3, &feedback_spec); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); double heap_num_0 = 2.718; double heap_num_1 = 2.0 * Smi::kMaxValue; Smi zero = Smi::zero(); diff --git a/test/unittests/interpreter/constant-array-builder-unittest.cc b/test/unittests/interpreter/constant-array-builder-unittest.cc index 55f1cacf56..894aee16a4 100644 --- a/test/unittests/interpreter/constant-array-builder-unittest.cc +++ b/test/unittests/interpreter/constant-array-builder-unittest.cc @@ -6,6 +6,7 @@ #include "src/ast/ast-value-factory.h" #include "src/handles-inl.h" +#include "src/hash-seed-inl.h" #include "src/heap/factory.h" #include "src/interpreter/constant-array-builder.h" #include "src/isolate.h" @@ -34,7 +35,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateAllEntries) { CanonicalHandleScope canonical(isolate()); ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (size_t i = 0; i < k16BitCapacity; i++) { builder.Insert(i + 0.5); } @@ -84,7 +85,7 @@ TEST_F(ConstantArrayBuilderTest, ToLargeFixedArrayWithReservations) { CanonicalHandleScope canonical(isolate()); ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); static const int kNumberOfElements = 37373; for (int i = 0; i < kNumberOfElements; i++) { builder.CommitReservedEntry(builder.CreateReservedEntry(), Smi::FromInt(i)); @@ -104,7 +105,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithIdx8Reservations) { for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (size_t i = 0; i < reserved; i++) { OperandSize operand_size = builder.CreateReservedEntry(); CHECK_EQ(operand_size, OperandSize::kByte); @@ -172,7 +173,7 @@ TEST_F(ConstantArrayBuilderTest, AllocateEntriesWithWideReservations) { for (size_t reserved = 1; reserved < k8BitCapacity; reserved *= 3) { ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (size_t i = 0; i < k8BitCapacity; i++) { builder.CommitReservedEntry(builder.CreateReservedEntry(), Smi::FromInt(static_cast(i))); @@ -217,7 +218,7 @@ TEST_F(ConstantArrayBuilderTest, GapFilledWhenLowReservationCommitted) { CanonicalHandleScope canonical(isolate()); ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (size_t i = 0; i < k8BitCapacity; i++) { OperandSize operand_size = builder.CreateReservedEntry(); CHECK_EQ(OperandSize::kByte, operand_size); @@ -283,7 +284,7 @@ TEST_F(ConstantArrayBuilderTest, HolesWithUnusedReservations) { static int k8BitCapacity = ConstantArrayBuilder::k8BitCapacity; ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (int i = 0; i < kNumberOfHoles; ++i) { CHECK_EQ(builder.CreateReservedEntry(), OperandSize::kByte); } @@ -316,7 +317,7 @@ TEST_F(ConstantArrayBuilderTest, ReservationsAtAllScales) { CanonicalHandleScope canonical(isolate()); ConstantArrayBuilder builder(zone()); AstValueFactory ast_factory(zone(), isolate()->ast_string_constants(), - isolate()->heap()->HashSeed()); + HashSeed(isolate())); for (int i = 0; i < 256; i++) { CHECK_EQ(builder.CreateReservedEntry(), OperandSize::kByte); } diff --git a/test/unittests/parser/ast-value-unittest.cc b/test/unittests/parser/ast-value-unittest.cc index 72e35a43a0..c30823b4b1 100644 --- a/test/unittests/parser/ast-value-unittest.cc +++ b/test/unittests/parser/ast-value-unittest.cc @@ -4,6 +4,7 @@ #include "src/ast/ast-value-factory.h" #include "src/ast/ast.h" +#include "src/hash-seed-inl.h" #include "src/heap/heap-inl.h" #include "src/isolate-inl.h" #include "src/zone/zone.h" @@ -17,7 +18,7 @@ class AstValueTest : public TestWithIsolateAndZone { protected: AstValueTest() : ast_value_factory_(zone(), i_isolate()->ast_string_constants(), - i_isolate()->heap()->HashSeed()), + HashSeed(i_isolate())), ast_node_factory_(&ast_value_factory_, zone()) {} Literal* NewBigInt(const char* str) {