Commit bd3005cc authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[stubs] Remove {CodeStub::GetCopy} support.

This removes the ability to create a copy of a code-stub with a given
replacement pattern applied. It is in preparation of having the ability
to write-protect code objects.

R=ishell@chromium.org
BUG=v8:6409

Change-Id: Id7528b3bfc53ece73d8c58b0ac96c6e5702a9d45
Reviewed-on: https://chromium-review.googlesource.com/654605Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47914}
parent 1f3f8f3e
......@@ -1573,7 +1573,6 @@ v8_source_set("v8_base") {
"src/field-index.h",
"src/field-type.cc",
"src/field-type.h",
"src/find-and-replace-pattern.h",
"src/fixed-dtoa.cc",
"src/fixed-dtoa.h",
"src/flag-definitions.h",
......
......@@ -109,14 +109,6 @@ Code::Flags CodeStub::GetCodeFlags() const {
return Code::ComputeFlags(GetCodeKind(), GetExtraICState());
}
Handle<Code> CodeStub::GetCodeCopy(const FindAndReplacePattern& pattern) {
Handle<Code> ic = GetCode();
ic = isolate()->factory()->CopyCode(ic);
ic->FindAndReplace(pattern);
RecordCodeGeneration(ic);
return ic;
}
void CodeStub::DeleteStubFromCacheForTesting() {
Heap* heap = isolate_->heap();
Handle<UnseededNumberDictionary> dict(heap->code_stubs());
......
......@@ -9,7 +9,6 @@
#include "src/assembler.h"
#include "src/codegen.h"
#include "src/factory.h"
#include "src/find-and-replace-pattern.h"
#include "src/globals.h"
#include "src/interface-descriptors.h"
#include "src/macro-assembler.h"
......@@ -143,9 +142,6 @@ class CodeStub : public ZoneObject {
// Retrieve the code for the stub. Generate the code if needed.
Handle<Code> GetCode();
// Retrieve the code for the stub, make and return a copy of the code.
Handle<Code> GetCodeCopy(const FindAndReplacePattern& pattern);
static Major MajorKeyFromKey(uint32_t key) {
return static_cast<Major>(MajorKeyBits::decode(key));
}
......
// 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<HeapObject> 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<HeapObject> replace_[kMaxCount];
friend class Code;
};
} // namespace internal
} // namespace v8
#endif // V8_FIND_AND_REPLACE_PATTERN_H_
......@@ -14032,58 +14032,6 @@ SafepointEntry Code::GetSafepointEntry(Address pc) {
}
Object* Code::FindNthObject(int n, Map* match_map) {
DCHECK(is_inline_cache_stub());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
Object* object = info->target_object();
if (object->IsWeakCell()) object = WeakCell::cast(object)->value();
if (object->IsHeapObject()) {
if (HeapObject::cast(object)->map() == match_map) {
if (--n == 0) return object;
}
}
}
return NULL;
}
AllocationSite* Code::FindFirstAllocationSite() {
Object* result = FindNthObject(1, GetHeap()->allocation_site_map());
return (result != NULL) ? AllocationSite::cast(result) : NULL;
}
Map* Code::FindFirstMap() {
Object* result = FindNthObject(1, GetHeap()->meta_map());
return (result != NULL) ? Map::cast(result) : NULL;
}
void Code::FindAndReplace(const FindAndReplacePattern& pattern) {
DCHECK(is_inline_cache_stub() || is_handler());
DisallowHeapAllocation no_allocation;
int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
STATIC_ASSERT(FindAndReplacePattern::kMaxCount < 32);
int current_pattern = 0;
for (RelocIterator it(this, mask); !it.done(); it.next()) {
RelocInfo* info = it.rinfo();
HeapObject* object = info->target_object();
if (object->IsWeakCell()) {
object = HeapObject::cast(WeakCell::cast(object)->value());
}
Map* map = object->map();
if (map == *pattern.find_[current_pattern]) {
info->set_target_object(*pattern.replace_[current_pattern]);
if (++current_pattern == pattern.count_) return;
}
}
UNREACHABLE();
}
namespace {
template <typename Code>
void SetStackFrameCacheCommon(Handle<Code> code,
......
......@@ -924,7 +924,6 @@ class Cell;
class ConsString;
class ElementsAccessor;
class EnumCache;
class FindAndReplacePattern;
class FixedArrayBase;
class PropertyArray;
class FunctionLiteral;
......@@ -3850,23 +3849,6 @@ class Code: public HeapObject {
// Get the safepoint entry for the given pc.
SafepointEntry GetSafepointEntry(Address pc);
// Find an object in a stub with a specified map
Object* FindNthObject(int n, Map* match_map);
// Find the first allocation site in an IC stub.
AllocationSite* FindFirstAllocationSite();
// Find the first map in an IC stub.
Map* FindFirstMap();
// For each (map-to-find, object-to-replace) pair in the pattern, this
// function replaces the corresponding placeholder in the code with the
// object-to-replace. The function assumes that pairs in the pattern come in
// the same order as the placeholders in the code.
// If the placeholder is a weak cell, then the value of weak cell is matched
// against the map-to-find.
void FindAndReplace(const FindAndReplacePattern& pattern);
// The entire code object including its header is copied verbatim to the
// snapshot so that it can be written in one, fast, memcpy during
// deserialization. The deserializer will overwrite some pointers, rather
......
......@@ -970,7 +970,6 @@
'field-index-inl.h',
'field-type.cc',
'field-type.h',
'find-and-replace-pattern.h',
'fixed-dtoa.cc',
'fixed-dtoa.h',
'flag-definitions.h',
......
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