Commit a1547aa9 authored by Marja Hölttä's avatar Marja Hölttä Committed by Commit Bot

[objects.h splitting] Move out Code::FindAndReplacePattern.

It's needed by code-stubs.h and it was defined in objects-inl.h.
That cannot work without violating the include rules.

BUG=v8:5402
R=mstarzinger@chromium.org

Change-Id: Icb84b97de5622df8cf76e9fc4d117982901c99d9
Reviewed-on: https://chromium-review.googlesource.com/441845
Commit-Queue: Marja Hölttä <marja@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43195}
parent c8e6340a
...@@ -1403,6 +1403,7 @@ v8_source_set("v8_base") { ...@@ -1403,6 +1403,7 @@ v8_source_set("v8_base") {
"src/field-index.h", "src/field-index.h",
"src/field-type.cc", "src/field-type.cc",
"src/field-type.h", "src/field-type.h",
"src/find-and-replace-pattern.h",
"src/fixed-dtoa.cc", "src/fixed-dtoa.cc",
"src/fixed-dtoa.h", "src/fixed-dtoa.h",
"src/flag-definitions.h", "src/flag-definitions.h",
...@@ -2564,8 +2565,8 @@ group("v8_clusterfuzz") { ...@@ -2564,8 +2565,8 @@ group("v8_clusterfuzz") {
if (v8_multi_arch_build) { if (v8_multi_arch_build) {
deps += [ deps += [
":d8(//build/toolchain/linux:clang_x64)", ":d8(//build/toolchain/linux:clang_x64)",
":d8(//build/toolchain/linux:clang_x86)",
":d8(//build/toolchain/linux:clang_x64_v8_arm64)", ":d8(//build/toolchain/linux:clang_x64_v8_arm64)",
":d8(//build/toolchain/linux:clang_x86)",
":d8(//build/toolchain/linux:clang_x86_v8_arm)", ":d8(//build/toolchain/linux:clang_x86_v8_arm)",
] ]
} }
......
...@@ -104,8 +104,7 @@ Code::Flags CodeStub::GetCodeFlags() const { ...@@ -104,8 +104,7 @@ Code::Flags CodeStub::GetCodeFlags() const {
return Code::ComputeFlags(GetCodeKind(), GetExtraICState()); return Code::ComputeFlags(GetCodeKind(), GetExtraICState());
} }
Handle<Code> CodeStub::GetCodeCopy(const FindAndReplacePattern& pattern) {
Handle<Code> CodeStub::GetCodeCopy(const Code::FindAndReplacePattern& pattern) {
Handle<Code> ic = GetCode(); Handle<Code> ic = GetCode();
ic = isolate()->factory()->CopyCode(ic); ic = isolate()->factory()->CopyCode(ic);
ic->FindAndReplace(pattern); ic->FindAndReplace(pattern);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "src/allocation.h" #include "src/allocation.h"
#include "src/assembler.h" #include "src/assembler.h"
#include "src/codegen.h" #include "src/codegen.h"
#include "src/find-and-replace-pattern.h"
#include "src/globals.h" #include "src/globals.h"
#include "src/ic/ic-state.h" #include "src/ic/ic-state.h"
#include "src/interface-descriptors.h" #include "src/interface-descriptors.h"
...@@ -175,7 +176,7 @@ class CodeStub BASE_EMBEDDED { ...@@ -175,7 +176,7 @@ class CodeStub BASE_EMBEDDED {
Handle<Code> GetCode(); Handle<Code> GetCode();
// Retrieve the code for the stub, make and return a copy of the code. // Retrieve the code for the stub, make and return a copy of the code.
Handle<Code> GetCodeCopy(const Code::FindAndReplacePattern& pattern); Handle<Code> GetCodeCopy(const FindAndReplacePattern& pattern);
static Major MajorKeyFromKey(uint32_t key) { static Major MajorKeyFromKey(uint32_t key) {
return static_cast<Major>(MajorKeyBits::decode(key)); return static_cast<Major>(MajorKeyBits::decode(key));
...@@ -919,7 +920,7 @@ class StoreGlobalStub : public TurboFanCodeStub { ...@@ -919,7 +920,7 @@ class StoreGlobalStub : public TurboFanCodeStub {
Handle<Code> GetCodeCopyFromTemplate(Handle<JSGlobalObject> global, Handle<Code> GetCodeCopyFromTemplate(Handle<JSGlobalObject> global,
Handle<PropertyCell> cell) { Handle<PropertyCell> cell) {
Code::FindAndReplacePattern pattern; FindAndReplacePattern pattern;
if (check_global()) { if (check_global()) {
pattern.Add(handle(global_map_placeholder(isolate())->map()), pattern.Add(handle(global_map_placeholder(isolate())->map()),
Map::WeakCellForMap(Handle<Map>(global->map()))); Map::WeakCellForMap(Handle<Map>(global->map())));
...@@ -1053,7 +1054,7 @@ class BinaryOpICWithAllocationSiteStub final : public PlatformCodeStub { ...@@ -1053,7 +1054,7 @@ class BinaryOpICWithAllocationSiteStub final : public PlatformCodeStub {
static void GenerateAheadOfTime(Isolate* isolate); static void GenerateAheadOfTime(Isolate* isolate);
Handle<Code> GetCodeCopyFromTemplate(Handle<AllocationSite> allocation_site) { Handle<Code> GetCodeCopyFromTemplate(Handle<AllocationSite> allocation_site) {
Code::FindAndReplacePattern pattern; FindAndReplacePattern pattern;
pattern.Add(isolate()->factory()->undefined_map(), allocation_site); pattern.Add(isolate()->factory()->undefined_map(), allocation_site);
return CodeStub::GetCodeCopy(pattern); return CodeStub::GetCodeCopy(pattern);
} }
......
// Copyright 2017 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_FIND_AND_REPLACE_PATTERN_H_
#define V8_FIND_AND_REPLACE_PATTERN_H_
#include "src/handles.h"
namespace v8 {
namespace internal {
class Map;
class Object;
class FindAndReplacePattern {
public:
FindAndReplacePattern() : count_(0) {}
void Add(Handle<Map> map_to_find, Handle<Object> obj_to_replace) {
DCHECK(count_ < kMaxCount);
find_[count_] = map_to_find;
replace_[count_] = obj_to_replace;
++count_;
}
private:
static const int kMaxCount = 4;
int count_;
Handle<Map> find_[kMaxCount];
Handle<Object> replace_[kMaxCount];
friend class Code;
};
} // namespace internal
} // namespace v8
#endif // V8_FIND_AND_REPLACE_PATTERN_H_
...@@ -5258,23 +5258,6 @@ bool Code::IsWeakObjectInOptimizedCode(Object* object) { ...@@ -5258,23 +5258,6 @@ bool Code::IsWeakObjectInOptimizedCode(Object* object) {
} }
class Code::FindAndReplacePattern {
public:
FindAndReplacePattern() : count_(0) { }
void Add(Handle<Map> map_to_find, Handle<Object> obj_to_replace) {
DCHECK(count_ < kMaxCount);
find_[count_] = map_to_find;
replace_[count_] = obj_to_replace;
++count_;
}
private:
static const int kMaxCount = 4;
int count_;
Handle<Map> find_[kMaxCount];
Handle<Object> replace_[kMaxCount];
friend class Code;
};
int AbstractCode::instruction_size() { int AbstractCode::instruction_size() {
if (IsCode()) { if (IsCode()) {
return GetCode()->instruction_size(); return GetCode()->instruction_size();
......
...@@ -928,6 +928,7 @@ class AllocationSiteUsageContext; ...@@ -928,6 +928,7 @@ class AllocationSiteUsageContext;
class Cell; class Cell;
class ConsString; class ConsString;
class ElementsAccessor; class ElementsAccessor;
class FindAndReplacePattern;
class FixedArrayBase; class FixedArrayBase;
class FunctionLiteral; class FunctionLiteral;
class JSGlobalObject; class JSGlobalObject;
...@@ -5093,7 +5094,6 @@ class Code: public HeapObject { ...@@ -5093,7 +5094,6 @@ class Code: public HeapObject {
// Find the first map in an IC stub. // Find the first map in an IC stub.
Map* FindFirstMap(); Map* FindFirstMap();
class FindAndReplacePattern;
// For each (map-to-find, object-to-replace) pair in the pattern, this // For each (map-to-find, object-to-replace) pair in the pattern, this
// function replaces the corresponding placeholder in the code with the // function replaces the corresponding placeholder in the code with the
// object-to-replace. The function assumes that pairs in the pattern come in // object-to-replace. The function assumes that pairs in the pattern come in
......
...@@ -902,6 +902,7 @@ ...@@ -902,6 +902,7 @@
'field-index-inl.h', 'field-index-inl.h',
'field-type.cc', 'field-type.cc',
'field-type.h', 'field-type.h',
'find-and-replace-pattern.h',
'fixed-dtoa.cc', 'fixed-dtoa.cc',
'fixed-dtoa.h', 'fixed-dtoa.h',
'flag-definitions.h', 'flag-definitions.h',
...@@ -1085,12 +1086,12 @@ ...@@ -1085,12 +1086,12 @@
'objects-printer.cc', 'objects-printer.cc',
'objects.cc', 'objects.cc',
'objects.h', 'objects.h',
'objects/literal-objects.cc',
'objects/literal-objects.h',
'objects/module-info.h', 'objects/module-info.h',
'objects/object-macros.h', 'objects/object-macros.h',
'objects/object-macros-undef.h', 'objects/object-macros-undef.h',
'objects/regexp-match-info.h', 'objects/regexp-match-info.h',
'objects/literal-objects.cc',
'objects/literal-objects.h',
'objects/scope-info.cc', 'objects/scope-info.cc',
'objects/scope-info.h', 'objects/scope-info.h',
'ostreams.cc', 'ostreams.cc',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment