[ubsan] Port SharedFunctionInfo to the new design

Bug: v8:3770
Change-Id: If405611d359d29ae1958beebd9202e068434a621
Reviewed-on: https://chromium-review.googlesource.com/c/1350286
Commit-Queue: Jakob Kummerow <jkummerow@chromium.org>
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: Michael Starzinger <mstarzinger@chromium.org>
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57918}
This commit is contained in:
Jakob Kummerow 2018-11-28 11:57:30 -08:00 committed by Commit Bot
parent 9436e8a817
commit 81620900e9
74 changed files with 310 additions and 301 deletions

View File

@ -756,8 +756,7 @@ StartupData SnapshotCreator::CreateBlob(
i::HeapIterator heap_iterator(isolate->heap());
while (i::HeapObject* current_obj = heap_iterator.next()) {
if (current_obj->IsSharedFunctionInfo()) {
i::SharedFunctionInfo* shared =
i::SharedFunctionInfo::cast(current_obj);
i::SharedFunctionInfo shared = i::SharedFunctionInfo::cast(current_obj);
if (shared->CanDiscardCompiled()) {
sfis_to_clear.emplace_back(shared, isolate);
}
@ -2143,7 +2142,7 @@ Local<PrimitiveArray> ScriptOrModule::GetHostDefinedOptions() {
Local<UnboundScript> Script::GetUnboundScript() {
i::Handle<i::Object> obj = Utils::OpenHandle(this);
i::SharedFunctionInfo* sfi = i::JSFunction::cast(*obj)->shared();
i::SharedFunctionInfo sfi = i::JSFunction::cast(*obj)->shared();
i::Isolate* isolate = sfi->GetIsolate();
return ToApiHandle<UnboundScript>(i::handle(sfi, isolate));
}
@ -9578,7 +9577,8 @@ void debug::ResetBlackboxedStateCache(Isolate* v8_isolate,
i::DisallowHeapAllocation no_gc;
i::SharedFunctionInfo::ScriptIterator iter(isolate,
*Utils::OpenHandle(*script));
while (i::SharedFunctionInfo* info = iter.Next()) {
for (i::SharedFunctionInfo info = iter.Next(); !info.is_null();
info = iter.Next()) {
if (info->HasDebugInfo()) {
info->GetDebugInfo()->set_computed_debug_is_blackboxed(false);
}

View File

@ -63,20 +63,20 @@ bool AreStdlibMembersValid(Isolate* isolate, Handle<JSReceiver> stdlib,
Handle<Object> value = JSReceiver::GetDataProperty(stdlib, name);
if (!value->IsNaN()) return false;
}
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
if (members.Contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##FName); \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
STATIC_CHAR_VECTOR(#fname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
if (!value->IsJSFunction()) return false; \
SharedFunctionInfo* shared = Handle<JSFunction>::cast(value)->shared(); \
if (!shared->HasBuiltinId() || \
shared->builtin_id() != Builtins::kMath##FName) { \
return false; \
} \
DCHECK_EQ(shared->GetCode(), \
isolate->builtins()->builtin(Builtins::kMath##FName)); \
#define STDLIB_MATH_FUNC(fname, FName, ignore1, ignore2) \
if (members.Contains(wasm::AsmJsParser::StandardMember::kMath##FName)) { \
members.Remove(wasm::AsmJsParser::StandardMember::kMath##FName); \
Handle<Name> name(isolate->factory()->InternalizeOneByteString( \
STATIC_CHAR_VECTOR(#fname))); \
Handle<Object> value = StdlibMathMember(isolate, stdlib, name); \
if (!value->IsJSFunction()) return false; \
SharedFunctionInfo shared = Handle<JSFunction>::cast(value)->shared(); \
if (!shared->HasBuiltinId() || \
shared->builtin_id() != Builtins::kMath##FName) { \
return false; \
} \
DCHECK_EQ(shared->GetCode(), \
isolate->builtins()->builtin(Builtins::kMath##FName)); \
}
STDLIB_MATH_FUNCTION_LIST(STDLIB_MATH_FUNC)
#undef STDLIB_MATH_FUNC

View File

@ -11,6 +11,7 @@
#include "src/globals.h"
#include "src/objects/code.h"
#include "src/objects/name.h"
#include "src/objects/shared-function-info.h"
#include "src/objects/string.h"
#include "src/vector.h"
@ -76,10 +77,10 @@ class CodeEventListener {
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name name) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source) = 0;
SharedFunctionInfo shared, Name source) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source,
int line, int column) = 0;
SharedFunctionInfo shared, Name source, int line,
int column) = 0;
virtual void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) = 0;
virtual void CallbackEvent(Name name, Address entry_point) = 0;
@ -90,7 +91,7 @@ class CodeEventListener {
virtual void SharedFunctionInfoMoveEvent(Address from, Address to) = 0;
virtual void CodeMovingGCEvent() = 0;
virtual void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) = 0;
SharedFunctionInfo shared) = 0;
virtual void CodeDeoptEvent(Code code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) = 0;
@ -132,11 +133,11 @@ class CodeEventDispatcher {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, name));
}
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name name) {
SharedFunctionInfo shared, Name name) {
CODE_EVENT_DISPATCH(CodeCreateEvent(tag, code, shared, name));
}
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source, int line,
SharedFunctionInfo shared, Name source, int line,
int column) {
CODE_EVENT_DISPATCH(
CodeCreateEvent(tag, code, shared, source, line, column));
@ -164,7 +165,7 @@ class CodeEventDispatcher {
CODE_EVENT_DISPATCH(SharedFunctionInfoMoveEvent(from, to));
}
void CodeMovingGCEvent() { CODE_EVENT_DISPATCH(CodeMovingGCEvent()); }
void CodeDisableOptEvent(AbstractCode code, SharedFunctionInfo* shared) {
void CodeDisableOptEvent(AbstractCode code, SharedFunctionInfo shared) {
CODE_EVENT_DISPATCH(CodeDisableOptEvent(code, shared));
}
void CodeDeoptEvent(Code code, DeoptimizeKind kind, Address pc,

View File

@ -98,7 +98,7 @@ bool CompilerDispatcher::IsEnqueued(JobId job_id) const {
}
void CompilerDispatcher::RegisterSharedFunctionInfo(
JobId job_id, SharedFunctionInfo* function) {
JobId job_id, SharedFunctionInfo function) {
DCHECK_NE(jobs_.find(job_id), jobs_.end());
if (trace_compiler_dispatcher_) {
@ -108,8 +108,8 @@ void CompilerDispatcher::RegisterSharedFunctionInfo(
}
// Make a global handle to the function.
Handle<SharedFunctionInfo> function_handle =
isolate_->global_handles()->Create(function);
Handle<SharedFunctionInfo> function_handle = Handle<SharedFunctionInfo>::cast(
isolate_->global_handles()->Create(function));
// Register mapping.
auto job_it = jobs_.find(job_id);

View File

@ -89,7 +89,7 @@ class V8_EXPORT_PRIVATE CompilerDispatcher {
const FunctionLiteral* function_literal);
// Registers the given |function| with the compilation job |job_id|.
void RegisterSharedFunctionInfo(JobId job_id, SharedFunctionInfo* function);
void RegisterSharedFunctionInfo(JobId job_id, SharedFunctionInfo function);
// Returns true if there is a pending job with the given id.
bool IsEnqueued(JobId job_id) const;

View File

@ -1833,7 +1833,8 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction(
ASSIGN_RETURN_ON_EXCEPTION(isolate, top_level, maybe_result, JSFunction);
SharedFunctionInfo::ScriptIterator infos(isolate, *script);
while (SharedFunctionInfo* info = infos.Next()) {
for (SharedFunctionInfo info = infos.Next(); !info.is_null();
info = infos.Next()) {
if (info->is_wrapped()) {
wrapped = Handle<SharedFunctionInfo>(info, isolate);
break;

View File

@ -145,7 +145,7 @@ CallDescriptor* Linkage::ComputeIncoming(Zone* zone,
if (!info->closure().is_null()) {
// If we are compiling a JS function, use a JS call descriptor,
// plus the receiver.
SharedFunctionInfo* shared = info->closure()->shared();
SharedFunctionInfo shared = info->closure()->shared();
return GetJSCallDescriptor(zone, info->is_osr(),
1 + shared->internal_formal_parameter_count(),
CallDescriptor::kCanUseRoots);

View File

@ -5092,7 +5092,7 @@ WasmImportCallKind GetWasmImportCallKind(Handle<JSReceiver> target,
// and whether it has a sloppy receiver.
if (target->IsJSFunction()) {
Handle<JSFunction> function = Handle<JSFunction>::cast(target);
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
// Check for math intrinsics.
#define COMPARE_SIG_FOR_BUILTIN(name) \

View File

@ -17,12 +17,12 @@ namespace v8 {
namespace internal {
class SharedToCounterMap
: public base::TemplateHashMapImpl<SharedFunctionInfo*, uint32_t,
: public base::TemplateHashMapImpl<SharedFunctionInfo, uint32_t,
base::KeyEqualityMatcher<void*>,
base::DefaultAllocationPolicy> {
public:
typedef base::TemplateHashMapEntry<SharedFunctionInfo*, uint32_t> Entry;
inline void Add(SharedFunctionInfo* key, uint32_t count) {
typedef base::TemplateHashMapEntry<SharedFunctionInfo, uint32_t> Entry;
inline void Add(SharedFunctionInfo key, uint32_t count) {
Entry* entry = LookupOrInsert(key, Hash(key), []() { return 0; });
uint32_t old_count = entry->value;
if (UINT32_MAX - count < old_count) {
@ -32,28 +32,28 @@ class SharedToCounterMap
}
}
inline uint32_t Get(SharedFunctionInfo* key) {
inline uint32_t Get(SharedFunctionInfo key) {
Entry* entry = Lookup(key, Hash(key));
if (entry == nullptr) return 0;
return entry->value;
}
private:
static uint32_t Hash(SharedFunctionInfo* key) {
return static_cast<uint32_t>(reinterpret_cast<intptr_t>(key));
static uint32_t Hash(SharedFunctionInfo key) {
return static_cast<uint32_t>(key.ptr());
}
DisallowHeapAllocation no_gc;
};
namespace {
int StartPosition(SharedFunctionInfo* info) {
int StartPosition(SharedFunctionInfo info) {
int start = info->function_token_position();
if (start == kNoSourcePosition) start = info->StartPosition();
return start;
}
bool CompareSharedFunctionInfo(SharedFunctionInfo* a, SharedFunctionInfo* b) {
bool CompareSharedFunctionInfo(SharedFunctionInfo a, SharedFunctionInfo b) {
int a_start = StartPosition(a);
int b_start = StartPosition(b);
if (a_start == b_start) return a->EndPosition() > b->EndPosition();
@ -72,7 +72,7 @@ void SortBlockData(std::vector<CoverageBlock>& v) {
std::sort(v.begin(), v.end(), CompareCoverageBlock);
}
std::vector<CoverageBlock> GetSortedBlockData(SharedFunctionInfo* shared) {
std::vector<CoverageBlock> GetSortedBlockData(SharedFunctionInfo shared) {
DCHECK(shared->HasCoverageInfo());
CoverageInfo coverage_info =
@ -383,7 +383,7 @@ void ClampToBinary(CoverageFunction* function) {
}
}
void ResetAllBlockCounts(SharedFunctionInfo* shared) {
void ResetAllBlockCounts(SharedFunctionInfo shared) {
DCHECK(shared->HasCoverageInfo());
CoverageInfo coverage_info =
@ -414,7 +414,7 @@ bool IsBinaryMode(debug::Coverage::Mode mode) {
}
}
void CollectBlockCoverage(CoverageFunction* function, SharedFunctionInfo* info,
void CollectBlockCoverage(CoverageFunction* function, SharedFunctionInfo info,
debug::Coverage::Mode mode) {
DCHECK(IsBlockMode(mode));
@ -500,7 +500,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
isolate->factory()->feedback_vectors_for_profiling_tools());
for (int i = 0; i < list->Length(); i++) {
FeedbackVector* vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo* shared = vector->shared_function_info();
SharedFunctionInfo shared = vector->shared_function_info();
DCHECK(shared->IsSubjectToDebugging());
uint32_t count = static_cast<uint32_t>(vector->invocation_count());
if (reset_count) vector->clear_invocation_count();
@ -517,7 +517,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
while (HeapObject* current_obj = heap_iterator.next()) {
if (!current_obj->IsFeedbackVector()) continue;
FeedbackVector* vector = FeedbackVector::cast(current_obj);
SharedFunctionInfo* shared = vector->shared_function_info();
SharedFunctionInfo shared = vector->shared_function_info();
if (!shared->IsSubjectToDebugging()) continue;
uint32_t count = static_cast<uint32_t>(vector->invocation_count());
counter_map.Add(shared, count);
@ -538,12 +538,13 @@ std::unique_ptr<Coverage> Coverage::Collect(
result->emplace_back(script_handle);
std::vector<CoverageFunction>* functions = &result->back().functions;
std::vector<SharedFunctionInfo*> sorted;
std::vector<SharedFunctionInfo> sorted;
{
// Sort functions by start position, from outer to inner functions.
SharedFunctionInfo::ScriptIterator infos(isolate, *script_handle);
while (SharedFunctionInfo* info = infos.Next()) {
for (SharedFunctionInfo info = infos.Next(); !info.is_null();
info = infos.Next()) {
sorted.push_back(info);
}
std::sort(sorted.begin(), sorted.end(), CompareSharedFunctionInfo);
@ -553,7 +554,7 @@ std::unique_ptr<Coverage> Coverage::Collect(
std::vector<size_t> nesting;
// Use sorted list to reconstruct function nesting.
for (SharedFunctionInfo* info : sorted) {
for (SharedFunctionInfo info : sorted) {
int start = StartPosition(info);
int end = info->EndPosition();
uint32_t count = counter_map.Get(info);
@ -634,7 +635,7 @@ void Coverage::SelectMode(Isolate* isolate, debug::Coverage::Mode mode) {
// If collecting binary coverage, reset
// SFI::has_reported_binary_coverage to avoid optimizing / inlining
// functions before they have reported coverage.
SharedFunctionInfo* shared = SharedFunctionInfo::cast(o);
SharedFunctionInfo shared = SharedFunctionInfo::cast(o);
shared->set_has_reported_binary_coverage(false);
} else if (o->IsFeedbackVector()) {
// In any case, clear any collected invocation counts.

View File

@ -38,7 +38,7 @@ std::unique_ptr<TypeProfile> TypeProfile::Collect(Isolate* isolate) {
// the list multiple times.
for (int i = 0; i < list->Length(); i++) {
FeedbackVector* vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo* info = vector->shared_function_info();
SharedFunctionInfo info = vector->shared_function_info();
DCHECK(info->IsSubjectToDebugging());
// Match vectors with script.
@ -87,7 +87,7 @@ void TypeProfile::SelectMode(Isolate* isolate, debug::TypeProfile::Mode mode) {
for (int i = 0; i < list->Length(); i++) {
FeedbackVector* vector = FeedbackVector::cast(list->Get(i));
SharedFunctionInfo* info = vector->shared_function_info();
SharedFunctionInfo info = vector->shared_function_info();
DCHECK(info->IsSubjectToDebugging());
if (info->feedback_metadata()->HasTypeProfileSlot()) {
FeedbackSlot slot = vector->GetTypeProfileSlot();

View File

@ -895,7 +895,7 @@ void Debug::PrepareStepOnThrow() {
while (!it.done()) {
JavaScriptFrame* frame = it.frame();
if (frame->LookupExceptionHandlerInTable(nullptr, nullptr) > 0) break;
std::vector<SharedFunctionInfo*> infos;
std::vector<SharedFunctionInfo> infos;
frame->GetFunctions(&infos);
current_frame_count -= infos.size();
it.Advance();
@ -1138,7 +1138,7 @@ void Debug::ClearOneShot() {
class RedirectActiveFunctions : public ThreadVisitor {
public:
explicit RedirectActiveFunctions(SharedFunctionInfo* shared)
explicit RedirectActiveFunctions(SharedFunctionInfo shared)
: shared_(shared) {
DCHECK(shared->HasBytecodeArray());
}
@ -1157,7 +1157,7 @@ class RedirectActiveFunctions : public ThreadVisitor {
}
private:
SharedFunctionInfo* shared_;
SharedFunctionInfo shared_;
DisallowHeapAllocation no_gc_;
};
@ -1258,7 +1258,7 @@ void Debug::InstallDebugBreakTrampoline() {
continue;
} else if (obj->IsJSFunction()) {
JSFunction* fun = JSFunction::cast(obj);
SharedFunctionInfo* shared = fun->shared();
SharedFunctionInfo shared = fun->shared();
if (!shared->HasDebugInfo()) continue;
if (!shared->GetDebugInfo()->CanBreakAtEntry()) continue;
if (!fun->is_compiled()) {
@ -1321,7 +1321,7 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
HandleScope scope(isolate_);
std::vector<Handle<SharedFunctionInfo>> candidates;
SharedFunctionInfo::ScriptIterator iterator(isolate_, *script);
for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
for (SharedFunctionInfo info = iterator.Next(); !info.is_null();
info = iterator.Next()) {
if (info->EndPosition() < start_position ||
info->StartPosition() >= end_position) {
@ -1362,12 +1362,11 @@ bool Debug::GetPossibleBreakpoints(Handle<Script> script, int start_position,
class SharedFunctionInfoFinder {
public:
explicit SharedFunctionInfoFinder(int target_position)
: current_candidate_(nullptr),
current_candidate_closure_(nullptr),
: current_candidate_closure_(nullptr),
current_start_position_(kNoSourcePosition),
target_position_(target_position) {}
void NewCandidate(SharedFunctionInfo* shared, JSFunction* closure = nullptr) {
void NewCandidate(SharedFunctionInfo shared, JSFunction* closure = nullptr) {
if (!shared->IsSubjectToDebugging()) return;
int start_position = shared->function_token_position();
if (start_position == kNoSourcePosition) {
@ -1377,7 +1376,7 @@ class SharedFunctionInfoFinder {
if (start_position > target_position_) return;
if (target_position_ > shared->EndPosition()) return;
if (current_candidate_ != nullptr) {
if (!current_candidate_.is_null()) {
if (current_start_position_ == start_position &&
shared->EndPosition() == current_candidate_->EndPosition()) {
// If we already have a matching closure, do not throw it away.
@ -1397,12 +1396,12 @@ class SharedFunctionInfoFinder {
current_candidate_closure_ = closure;
}
SharedFunctionInfo* Result() { return current_candidate_; }
SharedFunctionInfo Result() { return current_candidate_; }
JSFunction* ResultClosure() { return current_candidate_closure_; }
private:
SharedFunctionInfo* current_candidate_;
SharedFunctionInfo current_candidate_;
JSFunction* current_candidate_closure_;
int current_start_position_;
int target_position_;
@ -1424,16 +1423,16 @@ Handle<Object> Debug::FindSharedFunctionInfoInScript(Handle<Script> script,
// If there is no shared function info for this script at all, there is
// no point in looking for it by walking the heap.
SharedFunctionInfo* shared;
SharedFunctionInfo shared;
{
SharedFunctionInfoFinder finder(position);
SharedFunctionInfo::ScriptIterator iterator(isolate_, *script);
for (SharedFunctionInfo* info = iterator.Next(); info != nullptr;
for (SharedFunctionInfo info = iterator.Next(); !info.is_null();
info = iterator.Next()) {
finder.NewCandidate(info);
}
shared = finder.Result();
if (shared == nullptr) break;
if (shared.is_null()) break;
// We found it if it's already compiled.
if (shared->is_compiled()) {
Handle<SharedFunctionInfo> shared_handle(shared, isolate_);
@ -1886,7 +1885,7 @@ int Debug::CurrentFrameCount() {
int counter = 0;
while (!it.done()) {
if (it.frame()->is_optimized()) {
std::vector<SharedFunctionInfo*> infos;
std::vector<SharedFunctionInfo> infos;
OptimizedFrame::cast(it.frame())->GetFunctions(&infos);
counter += infos.size();
} else {
@ -2242,7 +2241,7 @@ bool Debug::PerformSideEffectCheckAtBytecode(InterpretedFrame* frame) {
using interpreter::Bytecode;
DCHECK_EQ(isolate_->debug_execution_mode(), DebugInfo::kSideEffects);
SharedFunctionInfo* shared = frame->function()->shared();
SharedFunctionInfo shared = frame->function()->shared();
BytecodeArray bytecode_array = shared->GetBytecodeArray();
int offset = frame->GetBytecodeOffset();
interpreter::BytecodeArrayAccessor bytecode_accessor(

View File

@ -808,7 +808,7 @@ class FunctionDataMap : public ThreadVisitor {
FunctionData{literal, should_restart});
}
bool Lookup(SharedFunctionInfo* sfi, FunctionData** data) {
bool Lookup(SharedFunctionInfo sfi, FunctionData** data) {
int start_position = sfi->StartPosition();
if (!sfi->script()->IsScript() || start_position == -1) {
return false;
@ -827,20 +827,20 @@ class FunctionDataMap : public ThreadVisitor {
HeapIterator iterator(isolate->heap(), HeapIterator::kFilterUnreachable);
while (HeapObject* obj = iterator.next()) {
if (obj->IsSharedFunctionInfo()) {
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
SharedFunctionInfo sfi = SharedFunctionInfo::cast(obj);
FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue;
data->shared = handle(sfi, isolate);
} else if (obj->IsJSFunction()) {
JSFunction* js_function = JSFunction::cast(obj);
SharedFunctionInfo* sfi = js_function->shared();
SharedFunctionInfo sfi = js_function->shared();
FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue;
data->js_functions.emplace_back(js_function, isolate);
} else if (obj->IsJSGeneratorObject()) {
JSGeneratorObject* gen = JSGeneratorObject::cast(obj);
if (gen->is_closed()) continue;
SharedFunctionInfo* sfi = gen->function()->shared();
SharedFunctionInfo sfi = gen->function()->shared();
FunctionData* data = nullptr;
if (!Lookup(sfi, &data)) continue;
data->running_generators.emplace_back(gen, isolate);
@ -899,7 +899,7 @@ class FunctionDataMap : public ThreadVisitor {
return FuncId(script_id, start_position);
}
FuncId GetFuncId(int script_id, SharedFunctionInfo* sfi) {
FuncId GetFuncId(int script_id, SharedFunctionInfo sfi) {
DCHECK_EQ(script_id, Script::cast(sfi->script())->id());
int start_position = sfi->StartPosition();
DCHECK_NE(start_position, -1);
@ -1179,12 +1179,12 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
}
}
SharedFunctionInfo::ScriptIterator it(isolate, *new_script);
while (SharedFunctionInfo* sfi = it.Next()) {
for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) {
if (!sfi->HasBytecodeArray()) continue;
FixedArray constants = sfi->GetBytecodeArray()->constant_pool();
for (int i = 0; i < constants->length(); ++i) {
if (!constants->get(i)->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* inner_sfi =
SharedFunctionInfo inner_sfi =
SharedFunctionInfo::cast(constants->get(i));
// See if there is a mapping from this function's start position to a
// unchanged function's id.
@ -1194,7 +1194,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
// Grab that function id from the new script's SFI list, which should have
// already been updated in in the unchanged pass.
SharedFunctionInfo* old_unchanged_inner_sfi =
SharedFunctionInfo old_unchanged_inner_sfi =
SharedFunctionInfo::cast(new_script->shared_function_infos()
->Get(unchanged_it->second)
->GetHeapObject());
@ -1215,7 +1215,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
SharedFunctionInfo::ScriptIterator it(isolate, *new_script);
std::set<int> start_positions;
while (SharedFunctionInfo* sfi = it.Next()) {
for (SharedFunctionInfo sfi = it.Next(); !sfi.is_null(); sfi = it.Next()) {
DCHECK_EQ(sfi->script(), *new_script);
DCHECK_EQ(sfi->FunctionLiteralId(isolate), it.CurrentIndex());
// Don't check the start position of the top-level function, as it can
@ -1233,7 +1233,7 @@ void LiveEdit::PatchScript(Isolate* isolate, Handle<Script> script,
FixedArray constants = sfi->GetBytecodeArray()->constant_pool();
for (int i = 0; i < constants->length(); ++i) {
if (!constants->get(i)->IsSharedFunctionInfo()) continue;
SharedFunctionInfo* inner_sfi =
SharedFunctionInfo inner_sfi =
SharedFunctionInfo::cast(constants->get(i));
DCHECK_EQ(inner_sfi->script(), *new_script);
DCHECK_EQ(inner_sfi, new_script->shared_function_infos()

View File

@ -823,7 +823,7 @@ void Deoptimizer::DoComputeOutputFrames() {
void Deoptimizer::DoComputeInterpretedFrame(TranslatedFrame* translated_frame,
int frame_index,
bool goto_catch_handler) {
SharedFunctionInfo* shared = translated_frame->raw_shared_info();
SharedFunctionInfo shared = translated_frame->raw_shared_info();
TranslatedFrame::iterator value_iterator = translated_frame->begin();
bool is_bottommost = (0 == frame_index);
@ -1833,7 +1833,7 @@ unsigned Deoptimizer::ComputeInputFrameSize() const {
}
// static
unsigned Deoptimizer::ComputeInterpretedFixedSize(SharedFunctionInfo* shared) {
unsigned Deoptimizer::ComputeInterpretedFixedSize(SharedFunctionInfo shared) {
// The fixed part of the frame consists of the return address, frame
// pointer, function, context, bytecode offset and all the incoming arguments.
return ComputeIncomingArgumentSize(shared) +
@ -1841,7 +1841,7 @@ unsigned Deoptimizer::ComputeInterpretedFixedSize(SharedFunctionInfo* shared) {
}
// static
unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo* shared) {
unsigned Deoptimizer::ComputeIncomingArgumentSize(SharedFunctionInfo shared) {
int parameter_slots = shared->internal_formal_parameter_count() + 1;
if (kPadArguments) parameter_slots = RoundUp(parameter_slots, 2);
return parameter_slots * kPointerSize;
@ -2351,7 +2351,7 @@ Deoptimizer::DeoptInfo Deoptimizer::GetDeoptInfo(Code code, Address pc) {
// static
int Deoptimizer::ComputeSourcePositionFromBytecodeArray(
SharedFunctionInfo* shared, BailoutId node_id) {
SharedFunctionInfo shared, BailoutId node_id) {
DCHECK(shared->HasBytecodeArray());
return AbstractCode::cast(shared->GetBytecodeArray())
->SourcePosition(node_id.ToInt());
@ -2702,7 +2702,7 @@ void TranslatedValue::Handlify() {
}
TranslatedFrame TranslatedFrame::InterpretedFrame(
BailoutId bytecode_offset, SharedFunctionInfo* shared_info, int height,
BailoutId bytecode_offset, SharedFunctionInfo shared_info, int height,
int return_value_offset, int return_value_count) {
TranslatedFrame frame(kInterpretedFunction, shared_info, height,
return_value_offset, return_value_count);
@ -2710,35 +2710,34 @@ TranslatedFrame TranslatedFrame::InterpretedFrame(
return frame;
}
TranslatedFrame TranslatedFrame::ArgumentsAdaptorFrame(
SharedFunctionInfo* shared_info, int height) {
SharedFunctionInfo shared_info, int height) {
return TranslatedFrame(kArgumentsAdaptor, shared_info, height);
}
TranslatedFrame TranslatedFrame::ConstructStubFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height) {
BailoutId bailout_id, SharedFunctionInfo shared_info, int height) {
TranslatedFrame frame(kConstructStub, shared_info, height);
frame.node_id_ = bailout_id;
return frame;
}
TranslatedFrame TranslatedFrame::BuiltinContinuationFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height) {
BailoutId bailout_id, SharedFunctionInfo shared_info, int height) {
TranslatedFrame frame(kBuiltinContinuation, shared_info, height);
frame.node_id_ = bailout_id;
return frame;
}
TranslatedFrame TranslatedFrame::JavaScriptBuiltinContinuationFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height) {
BailoutId bailout_id, SharedFunctionInfo shared_info, int height) {
TranslatedFrame frame(kJavaScriptBuiltinContinuation, shared_info, height);
frame.node_id_ = bailout_id;
return frame;
}
TranslatedFrame TranslatedFrame::JavaScriptBuiltinContinuationWithCatchFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height) {
BailoutId bailout_id, SharedFunctionInfo shared_info, int height) {
TranslatedFrame frame(kJavaScriptBuiltinContinuationWithCatch, shared_info,
height);
frame.node_id_ = bailout_id;
@ -2770,10 +2769,10 @@ int TranslatedFrame::GetValueCount() {
void TranslatedFrame::Handlify() {
if (raw_shared_info_ != nullptr) {
if (!raw_shared_info_.is_null()) {
shared_info_ = Handle<SharedFunctionInfo>(raw_shared_info_,
raw_shared_info_->GetIsolate());
raw_shared_info_ = nullptr;
raw_shared_info_ = SharedFunctionInfo();
}
for (auto& value : values_) {
value.Handlify();
@ -2788,7 +2787,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
switch (opcode) {
case Translation::INTERPRETED_FRAME: {
BailoutId bytecode_offset = BailoutId(iterator->Next());
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
int return_value_offset = iterator->Next();
@ -2809,7 +2808,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
}
case Translation::ARGUMENTS_ADAPTOR_FRAME: {
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
if (trace_file != nullptr) {
@ -2822,7 +2821,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::CONSTRUCT_STUB_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
if (trace_file != nullptr) {
@ -2837,7 +2836,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::BUILTIN_CONTINUATION_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
if (trace_file != nullptr) {
@ -2856,7 +2855,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
if (trace_file != nullptr) {
@ -2874,7 +2873,7 @@ TranslatedFrame TranslatedState::CreateNextTranslatedFrame(
}
case Translation::JAVA_SCRIPT_BUILTIN_CONTINUATION_WITH_CATCH_FRAME: {
BailoutId bailout_id = BailoutId(iterator->Next());
SharedFunctionInfo* shared_info =
SharedFunctionInfo shared_info =
SharedFunctionInfo::cast(literal_array->get(iterator->Next()));
int height = iterator->Next();
if (trace_file != nullptr) {

View File

@ -173,8 +173,8 @@ class TranslatedFrame {
int return_value_offset() const { return return_value_offset_; }
int return_value_count() const { return return_value_count_; }
SharedFunctionInfo* raw_shared_info() const {
CHECK_NOT_NULL(raw_shared_info_);
SharedFunctionInfo raw_shared_info() const {
CHECK(!raw_shared_info_.is_null());
return raw_shared_info_;
}
@ -231,29 +231,30 @@ class TranslatedFrame {
// Constructor static methods.
static TranslatedFrame InterpretedFrame(BailoutId bytecode_offset,
SharedFunctionInfo* shared_info,
SharedFunctionInfo shared_info,
int height, int return_value_offset,
int return_value_count);
static TranslatedFrame AccessorFrame(Kind kind,
SharedFunctionInfo* shared_info);
static TranslatedFrame ArgumentsAdaptorFrame(SharedFunctionInfo* shared_info,
SharedFunctionInfo shared_info);
static TranslatedFrame ArgumentsAdaptorFrame(SharedFunctionInfo shared_info,
int height);
static TranslatedFrame ConstructStubFrame(BailoutId bailout_id,
SharedFunctionInfo* shared_info,
SharedFunctionInfo shared_info,
int height);
static TranslatedFrame BuiltinContinuationFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height);
BailoutId bailout_id, SharedFunctionInfo shared_info, int height);
static TranslatedFrame JavaScriptBuiltinContinuationFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height);
BailoutId bailout_id, SharedFunctionInfo shared_info, int height);
static TranslatedFrame JavaScriptBuiltinContinuationWithCatchFrame(
BailoutId bailout_id, SharedFunctionInfo* shared_info, int height);
BailoutId bailout_id, SharedFunctionInfo shared_info, int height);
static TranslatedFrame InvalidFrame() {
return TranslatedFrame(kInvalid, nullptr);
return TranslatedFrame(kInvalid, SharedFunctionInfo());
}
static void AdvanceIterator(std::deque<TranslatedValue>::iterator* iter);
TranslatedFrame(Kind kind, SharedFunctionInfo* shared_info = nullptr,
TranslatedFrame(Kind kind,
SharedFunctionInfo shared_info = SharedFunctionInfo(),
int height = 0, int return_value_offset = 0,
int return_value_count = 0)
: kind_(kind),
@ -269,7 +270,7 @@ class TranslatedFrame {
Kind kind_;
BailoutId node_id_;
SharedFunctionInfo* raw_shared_info_;
SharedFunctionInfo raw_shared_info_;
Handle<SharedFunctionInfo> shared_info_;
int height_;
int return_value_offset_;
@ -422,7 +423,7 @@ class Deoptimizer : public Malloced {
static DeoptInfo GetDeoptInfo(Code code, Address from);
static int ComputeSourcePositionFromBytecodeArray(SharedFunctionInfo* shared,
static int ComputeSourcePositionFromBytecodeArray(SharedFunctionInfo shared,
BailoutId node_id);
struct JumpTableEntry : public ZoneObject {
@ -586,9 +587,9 @@ class Deoptimizer : public Malloced {
unsigned ComputeInputFrameAboveFpFixedSize() const;
unsigned ComputeInputFrameSize() const;
static unsigned ComputeInterpretedFixedSize(SharedFunctionInfo* shared);
static unsigned ComputeInterpretedFixedSize(SharedFunctionInfo shared);
static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo* shared);
static unsigned ComputeIncomingArgumentSize(SharedFunctionInfo shared);
static unsigned ComputeOutgoingArgumentSize(Code code, unsigned bailout_id);
static void GenerateDeoptimizationEntries(MacroAssembler* masm, int count,

View File

@ -93,8 +93,8 @@ int FeedbackMetadata::GetSlotSize(FeedbackSlotKind kind) {
return 1;
}
ACCESSORS(FeedbackVector, shared_function_info, SharedFunctionInfo,
kSharedFunctionInfoOffset)
ACCESSORS2(FeedbackVector, shared_function_info, SharedFunctionInfo,
kSharedFunctionInfoOffset)
WEAK_ACCESSORS(FeedbackVector, optimized_code_weak_or_smi, kOptimizedCodeOffset)
INT32_ACCESSORS(FeedbackVector, length, kLengthOffset)
INT32_ACCESSORS(FeedbackVector, invocation_count, kInvocationCountOffset)

View File

@ -326,7 +326,7 @@ void FeedbackVector::SetOptimizationMarker(OptimizationMarker marker) {
}
void FeedbackVector::EvictOptimizedCodeMarkedForDeoptimization(
SharedFunctionInfo* shared, const char* reason) {
SharedFunctionInfo shared, const char* reason) {
MaybeObject slot = optimized_code_weak_or_smi();
if (slot->IsSmi()) {
return;

View File

@ -159,7 +159,7 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
// [shared_function_info]: The shared function info for the function with this
// feedback vector.
DECL_ACCESSORS(shared_function_info, SharedFunctionInfo)
DECL_ACCESSORS2(shared_function_info, SharedFunctionInfo)
// [optimized_code_weak_or_smi]: weak reference to optimized code or a Smi
// marker defining optimization behaviour.
@ -187,7 +187,7 @@ class FeedbackVector : public HeapObject, public NeverReadOnlySpaceObject {
inline bool has_optimized_code() const;
inline bool has_optimization_marker() const;
void ClearOptimizedCode();
void EvictOptimizedCodeMarkedForDeoptimization(SharedFunctionInfo* shared,
void EvictOptimizedCodeMarkedForDeoptimization(SharedFunctionInfo shared,
const char* reason);
static void SetOptimizedCode(Handle<FeedbackVector> vector,
Handle<Code> code);

View File

@ -1031,7 +1031,7 @@ bool JavaScriptFrame::IsConstructor() const {
bool JavaScriptFrame::HasInlinedFrames() const {
std::vector<SharedFunctionInfo*> functions;
std::vector<SharedFunctionInfo> functions;
GetFunctions(&functions);
return functions.size() > 1;
}
@ -1059,7 +1059,7 @@ Address JavaScriptFrame::GetCallerStackPointer() const {
}
void JavaScriptFrame::GetFunctions(
std::vector<SharedFunctionInfo*>* functions) const {
std::vector<SharedFunctionInfo>* functions) const {
DCHECK(functions->empty());
functions->push_back(function()->shared());
}
@ -1067,7 +1067,7 @@ void JavaScriptFrame::GetFunctions(
void JavaScriptFrame::GetFunctions(
std::vector<Handle<SharedFunctionInfo>>* functions) const {
DCHECK(functions->empty());
std::vector<SharedFunctionInfo*> raw_functions;
std::vector<SharedFunctionInfo> raw_functions;
GetFunctions(&raw_functions);
for (const auto& raw_function : raw_functions) {
functions->push_back(
@ -1127,7 +1127,7 @@ void JavaScriptFrame::PrintFunctionAndOffset(JSFunction* function,
function->PrintName(file);
PrintF(file, "+%d", code_offset);
if (print_line_number) {
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
int source_pos = code->SourcePosition(code_offset);
Object* maybe_script = shared->script();
if (maybe_script->IsScript()) {
@ -1192,7 +1192,7 @@ void JavaScriptFrame::CollectFunctionAndOffsetForICStats(JSFunction* function,
int code_offset) {
auto ic_stats = ICStats::instance();
ICInfo& ic_info = ic_stats->Current();
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
ic_info.function_name = ic_stats->GetOrCacheFunctionName(function);
ic_info.script_offset = code_offset;
@ -1603,7 +1603,7 @@ Object* OptimizedFrame::receiver() const {
}
void OptimizedFrame::GetFunctions(
std::vector<SharedFunctionInfo*>* functions) const {
std::vector<SharedFunctionInfo>* functions) const {
DCHECK(functions->empty());
DCHECK(is_optimized());
@ -1653,7 +1653,6 @@ void OptimizedFrame::GetFunctions(
}
}
int OptimizedFrame::StackSlotOffsetRelativeToFp(int slot_index) {
return StandardFrameConstants::kCallerSPOffset -
((slot_index + 1) * kPointerSize);
@ -1959,7 +1958,7 @@ Address WasmCompileLazyFrame::GetCallerStackPointer() const {
namespace {
void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared,
void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo shared,
Code code) {
if (FLAG_max_stack_trace_source_length != 0 && !code.is_null()) {
std::ostringstream os;
@ -1970,7 +1969,6 @@ void PrintFunctionSource(StringStream* accumulator, SharedFunctionInfo* shared,
}
}
} // namespace
@ -1993,7 +1991,7 @@ void JavaScriptFrame::Print(StringStream* accumulator,
// doesn't contain scope info, scope_info will return 0 for the number of
// parameters, stack local variables, context local variables, stack slots,
// or context slots.
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
ScopeInfo scope_info = shared->scope_info();
Object* script_obj = shared->script();
if (script_obj->IsScript()) {

View File

@ -717,7 +717,7 @@ class JavaScriptFrame : public StandardFrame {
Code unchecked_code() const override;
// Return a list with {SharedFunctionInfo} objects of this frame.
virtual void GetFunctions(std::vector<SharedFunctionInfo*>* functions) const;
virtual void GetFunctions(std::vector<SharedFunctionInfo>* functions) const;
void GetFunctions(std::vector<Handle<SharedFunctionInfo>>* functions) const;
@ -803,7 +803,7 @@ class OptimizedFrame : public JavaScriptFrame {
// Return a list with {SharedFunctionInfo} objects of this frame.
// The functions are ordered bottom-to-top (i.e. functions.last()
// is the top-most activation)
void GetFunctions(std::vector<SharedFunctionInfo*>* functions) const override;
void GetFunctions(std::vector<SharedFunctionInfo>* functions) const override;
void Summarize(std::vector<FrameSummary>* frames) const override;

View File

@ -953,7 +953,7 @@ class CodeDescription {
};
#endif
CodeDescription(const char* name, Code code, SharedFunctionInfo* shared,
CodeDescription(const char* name, Code code, SharedFunctionInfo shared,
LineInfo* lineinfo)
: name_(name), code_(code), shared_info_(shared), lineinfo_(lineinfo) {}
@ -968,7 +968,7 @@ class CodeDescription {
return kind == Code::OPTIMIZED_FUNCTION;
}
bool has_scope_info() const { return shared_info_ != nullptr; }
bool has_scope_info() const { return !shared_info_.is_null(); }
ScopeInfo scope_info() const {
DCHECK(has_scope_info());
@ -988,7 +988,7 @@ class CodeDescription {
}
bool has_script() {
return shared_info_ != nullptr && shared_info_->script()->IsScript();
return !shared_info_.is_null() && shared_info_->script()->IsScript();
}
Script* script() { return Script::cast(shared_info_->script()); }
@ -1008,7 +1008,7 @@ class CodeDescription {
#endif
std::unique_ptr<char[]> GetFilename() {
if (shared_info_ != nullptr) {
if (!shared_info_.is_null()) {
return String::cast(script()->name())->ToCString();
} else {
std::unique_ptr<char[]> result(new char[1]);
@ -1018,7 +1018,7 @@ class CodeDescription {
}
int GetScriptLineNumber(int pos) {
if (shared_info_ != nullptr) {
if (!shared_info_.is_null()) {
return script()->GetLineNumber(pos) + 1;
} else {
return 0;
@ -1028,7 +1028,7 @@ class CodeDescription {
private:
const char* name_;
Code code_;
SharedFunctionInfo* shared_info_;
SharedFunctionInfo shared_info_;
LineInfo* lineinfo_;
#if V8_TARGET_ARCH_X64
uintptr_t stack_state_start_addresses_[STACK_STATE_MAX];
@ -2082,7 +2082,7 @@ static void AddJITCodeEntry(CodeMap* map, const AddressRange& range,
RegisterCodeEntry(entry);
}
static void AddCode(const char* name, Code code, SharedFunctionInfo* shared,
static void AddCode(const char* name, Code code, SharedFunctionInfo shared,
LineInfo* lineinfo) {
DisallowHeapAllocation no_gc;
@ -2119,7 +2119,6 @@ static void AddCode(const char* name, Code code, SharedFunctionInfo* shared,
AddJITCodeEntry(code_map, range, entry, should_dump, name_hint);
}
void EventHandler(const v8::JitCodeEvent* event) {
if (!FLAG_gdbjit) return;
if (event->code_type != v8::JitCodeEvent::JIT_CODE) return;
@ -2134,9 +2133,9 @@ void EventHandler(const v8::JitCodeEvent* event) {
StringBuilder builder(buffer.start(), buffer.length());
builder.AddSubstring(event->name.str, static_cast<int>(event->name.len));
// It's called UnboundScript in the API but it's a SharedFunctionInfo.
SharedFunctionInfo* shared = event->script.IsEmpty()
? nullptr
: *Utils::OpenHandle(*event->script);
SharedFunctionInfo shared = event->script.IsEmpty()
? SharedFunctionInfo()
: *Utils::OpenHandle(*event->script);
AddCode(builder.Finalize(), code, shared, lineinfo);
break;
}

View File

@ -163,6 +163,7 @@ class Handle final : public HandleBase {
std::is_same<S, OrderedNameDictionary>::value ||
std::is_same<S, ScriptContextTable>::value ||
std::is_same<S, ScopeInfo>::value ||
std::is_same<S, SharedFunctionInfo>::value ||
std::is_same<S, SmallOrderedHashMap>::value ||
std::is_same<S, SmallOrderedHashSet>::value ||
std::is_same<S, SmallOrderedNameDictionary>::value ||

View File

@ -387,7 +387,7 @@ class ObjectStatsCollectorImpl {
void RecordVirtualMapDetails(Map map);
void RecordVirtualScriptDetails(Script* script);
void RecordVirtualExternalStringDetails(ExternalString script);
void RecordVirtualSharedFunctionInfoDetails(SharedFunctionInfo* info);
void RecordVirtualSharedFunctionInfoDetails(SharedFunctionInfo info);
void RecordVirtualJSFunctionDetails(JSFunction* function);
void RecordVirtualArrayBoilerplateDescription(
@ -837,7 +837,7 @@ void ObjectStatsCollectorImpl::RecordVirtualExternalStringDetails(
}
void ObjectStatsCollectorImpl::RecordVirtualSharedFunctionInfoDetails(
SharedFunctionInfo* info) {
SharedFunctionInfo info) {
// Uncompiled SharedFunctionInfo gets its own category.
if (!info->is_compiled()) {
RecordSimpleVirtualObjectStats(

View File

@ -179,6 +179,13 @@ int NewSpaceVisitor<ConcreteVisitor>::VisitJSApiObject(Map map,
return visitor->VisitJSObject(map, object);
}
template <typename ConcreteVisitor>
int NewSpaceVisitor<ConcreteVisitor>::VisitSharedFunctionInfo(
Map map, SharedFunctionInfo object) {
UNREACHABLE();
return 0;
}
template <typename ResultType, typename ConcreteVisitor>
ResultType HeapVisitor<ResultType, ConcreteVisitor>::VisitWeakArray(
Map map, HeapObject* object) {

View File

@ -66,7 +66,7 @@ class WasmInstanceObject;
V(PrototypeInfo, PrototypeInfo*) \
V(SeqOneByteString, SeqOneByteString) \
V(SeqTwoByteString, SeqTwoByteString) \
V(SharedFunctionInfo, SharedFunctionInfo*) \
V(SharedFunctionInfo, SharedFunctionInfo) \
V(SlicedString, SlicedString) \
V(SmallOrderedHashMap, SmallOrderedHashMap) \
V(SmallOrderedHashSet, SmallOrderedHashSet) \
@ -144,10 +144,7 @@ class NewSpaceVisitor : public HeapVisitor<int, ConcreteVisitor> {
return 0;
}
int VisitSharedFunctionInfo(Map map, SharedFunctionInfo* object) {
UNREACHABLE();
return 0;
}
int VisitSharedFunctionInfo(Map map, SharedFunctionInfo object);
int VisitJSWeakCell(Map map, JSWeakCell* js_weak_cell) {
UNREACHABLE();

View File

@ -79,7 +79,7 @@ const char* ICStats::GetOrCacheFunctionName(JSFunction* function) {
if (function_name_map_.find(function) != function_name_map_.end()) {
return function_name_map_[function].get();
}
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
ic_infos_[pos_].is_optimized = function->IsOptimized();
char* function_name = shared->DebugName()->ToCString().release();
function_name_map_.insert(

View File

@ -3563,7 +3563,7 @@ void Isolate::MaybeInitializeVectorListFromHeap() {
if (!current_obj->IsFeedbackVector()) continue;
FeedbackVector* vector = FeedbackVector::cast(current_obj);
SharedFunctionInfo* shared = vector->shared_function_info();
SharedFunctionInfo shared = vector->shared_function_info();
// No need to preserve the feedback vector for non-user-visible functions.
if (!shared->IsSubjectToDebugging()) continue;

View File

@ -71,8 +71,7 @@ static v8::CodeEventType GetCodeEventTypeForTag(
PROFILE(isolate_, Call); \
}
static const char* ComputeMarker(SharedFunctionInfo* shared,
AbstractCode code) {
static const char* ComputeMarker(SharedFunctionInfo shared, AbstractCode code) {
switch (code->kind()) {
case AbstractCode::INTERPRETED_FUNCTION:
return shared->optimization_disabled() ? "" : "~";
@ -188,19 +187,21 @@ void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, const char* comment) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(comment);
LogRecordedBuffer(code, nullptr, name_buffer_->get(), name_buffer_->size());
LogRecordedBuffer(code, SharedFunctionInfo(), name_buffer_->get(),
name_buffer_->size());
}
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name name) {
name_buffer_->Init(tag);
name_buffer_->AppendName(name);
LogRecordedBuffer(code, nullptr, name_buffer_->get(), name_buffer_->size());
LogRecordedBuffer(code, SharedFunctionInfo(), name_buffer_->get(),
name_buffer_->size());
}
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code,
SharedFunctionInfo* shared, Name name) {
SharedFunctionInfo shared, Name name) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
name_buffer_->AppendName(name);
@ -209,7 +210,7 @@ void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void CodeEventLogger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code,
SharedFunctionInfo* shared, Name source,
SharedFunctionInfo shared, Name source,
int line, int column) {
name_buffer_->Init(tag);
name_buffer_->AppendBytes(ComputeMarker(shared, code));
@ -248,7 +249,8 @@ void CodeEventLogger::CodeCreateEvent(LogEventsAndTags tag,
void CodeEventLogger::RegExpCodeCreateEvent(AbstractCode code, String source) {
name_buffer_->Init(CodeEventListener::REG_EXP_TAG);
name_buffer_->AppendString(source);
LogRecordedBuffer(code, nullptr, name_buffer_->get(), name_buffer_->size());
LogRecordedBuffer(code, SharedFunctionInfo(), name_buffer_->get(),
name_buffer_->size());
}
// Linux perf tool logging support
@ -259,10 +261,10 @@ class PerfBasicLogger : public CodeEventLogger {
void CodeMoveEvent(AbstractCode from, AbstractCode to) override {}
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
private:
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) override;
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override;
@ -315,7 +317,7 @@ void PerfBasicLogger::WriteLogRecordedBuffer(uintptr_t address, int size,
size, name_length, name);
}
void PerfBasicLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo*,
void PerfBasicLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo,
const char* name, int length) {
if (FLAG_perf_basic_prof_only_functions &&
(code->kind() != AbstractCode::INTERPRETED_FUNCTION &&
@ -411,7 +413,7 @@ void ExternalCodeEventListener::CodeCreateEvent(
void ExternalCodeEventListener::CodeCreateEvent(
CodeEventListener::LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name name) {
SharedFunctionInfo shared, Name name) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, Handle<Name>(name, isolate_))
.ToHandleChecked();
@ -432,7 +434,7 @@ void ExternalCodeEventListener::CodeCreateEvent(
void ExternalCodeEventListener::CodeCreateEvent(
CodeEventListener::LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source, int line, int column) {
SharedFunctionInfo shared, Name source, int line, int column) {
Handle<String> name_string =
Name::ToFunctionName(isolate_, Handle<Name>(shared->Name(), isolate_))
.ToHandleChecked();
@ -484,12 +486,12 @@ class LowLevelLogger : public CodeEventLogger {
void CodeMoveEvent(AbstractCode from, AbstractCode to) override;
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
void SnapshotPositionEvent(HeapObject* obj, int pos);
void CodeMovingGCEvent() override;
private:
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) override;
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override;
@ -577,7 +579,7 @@ void LowLevelLogger::LogCodeInfo() {
LogWriteBytes(arch, sizeof(arch));
}
void LowLevelLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo*,
void LowLevelLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo,
const char* name, int length) {
CodeCreateStruct event;
event.name_size = length;
@ -627,7 +629,7 @@ class JitLogger : public CodeEventLogger {
void CodeMoveEvent(AbstractCode from, AbstractCode to) override;
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
void AddCodeLinePosInfoEvent(void* jit_handler_data, int pc_offset,
int position,
JitCodeEvent::PositionType position_type);
@ -636,7 +638,7 @@ class JitLogger : public CodeEventLogger {
void EndCodePosInfoEvent(Address start_address, void* jit_handler_data);
private:
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) override;
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override;
@ -648,7 +650,7 @@ class JitLogger : public CodeEventLogger {
JitLogger::JitLogger(Isolate* isolate, JitCodeEventHandler code_event_handler)
: CodeEventLogger(isolate), code_event_handler_(code_event_handler) {}
void JitLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void JitLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) {
JitCodeEvent event;
memset(static_cast<void*>(&event), 0, sizeof(event));
@ -658,7 +660,7 @@ void JitLogger::LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
code->IsCode() ? JitCodeEvent::JIT_CODE : JitCodeEvent::BYTE_CODE;
event.code_len = code->InstructionSize();
Handle<SharedFunctionInfo> shared_function_handle;
if (shared && shared->script()->IsScript()) {
if (!shared.is_null() && shared->script()->IsScript()) {
shared_function_handle =
Handle<SharedFunctionInfo>(shared, shared->GetIsolate());
}
@ -1235,7 +1237,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
}
void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name name) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
@ -1279,7 +1281,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
// the SharedFunctionInfo object, we left it to caller
// to leave logging functions free from heap allocations.
void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name source, int line, int column) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
@ -1373,8 +1375,7 @@ void Logger::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
msg.WriteToLogFile();
}
void Logger::CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) {
void Logger::CodeDisableOptEvent(AbstractCode code, SharedFunctionInfo shared) {
if (!is_listening_to_code_events()) return;
if (!FLAG_log_code || !log_->IsEnabled()) return;
Log::MessageBuilder msg(log_);
@ -1525,7 +1526,7 @@ void Logger::FunctionEvent(const char* reason, int script_id, double time_delta,
}
void Logger::CompilationCacheEvent(const char* action, const char* cache_type,
SharedFunctionInfo* sfi) {
SharedFunctionInfo sfi) {
if (!log_->IsEnabled() || !FLAG_log_function_events) return;
Log::MessageBuilder msg(log_);
int script_id = -1;
@ -1693,7 +1694,7 @@ void Logger::MapEvent(const char* type, Map from, Map to, const char* reason,
if (name_or_sfi->IsName()) {
msg << Name::cast(name_or_sfi);
} else if (name_or_sfi->IsSharedFunctionInfo()) {
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(name_or_sfi);
SharedFunctionInfo sfi = SharedFunctionInfo::cast(name_or_sfi);
msg << sfi->DebugName();
#if V8_SFI_HAS_UNIQUE_ID
msg << " " << sfi->unique_id();
@ -1741,8 +1742,7 @@ void Logger::LogFailure() {
StopProfiler();
}
static void AddFunctionAndCode(SharedFunctionInfo* sfi,
AbstractCode code_object,
static void AddFunctionAndCode(SharedFunctionInfo sfi, AbstractCode code_object,
Handle<SharedFunctionInfo>* sfis,
Handle<AbstractCode>* code_objects, int offset) {
if (sfis != nullptr) {
@ -1765,7 +1765,7 @@ static int EnumerateCompiledFunctions(Heap* heap,
for (HeapObject* obj = iterator.next(); obj != nullptr;
obj = iterator.next()) {
if (obj->IsSharedFunctionInfo()) {
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
SharedFunctionInfo sfi = SharedFunctionInfo::cast(obj);
if (sfi->is_compiled() &&
(!sfi->script()->IsScript() ||
Script::cast(sfi->script())->HasValidSource())) {
@ -1777,7 +1777,7 @@ static int EnumerateCompiledFunctions(Heap* heap,
// Given that we no longer iterate over all optimized JSFunctions, we need
// to take care of this here.
JSFunction* function = JSFunction::cast(obj);
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(function->shared());
SharedFunctionInfo sfi = SharedFunctionInfo::cast(function->shared());
Object* maybe_script = sfi->script();
if (maybe_script->IsScript() &&
!Script::cast(maybe_script)->HasValidSource()) {

View File

@ -173,7 +173,7 @@ class Logger : public CodeEventListener {
size_t function_name_length = 0);
void CompilationCacheEvent(const char* action, const char* cache_type,
SharedFunctionInfo* sfi);
SharedFunctionInfo sfi);
void ScriptEvent(ScriptEventType type, int script_id);
void ScriptDetails(Script* script);
@ -200,17 +200,17 @@ class Logger : public CodeEventListener {
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name source, int line, int column) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
const wasm::WasmCode* code,
wasm::WasmName name) override;
// Emits a code deoptimization event.
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override;
SharedFunctionInfo shared) override;
void CodeMovingGCEvent() override;
// Emits a code create event for a RegExp.
void RegExpCodeCreateEvent(AbstractCode code, String source) override;
@ -409,9 +409,9 @@ class CodeEventLogger : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name name) override;
SharedFunctionInfo shared, Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source, int line,
SharedFunctionInfo shared, Name source, int line,
int column) override;
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) override;
@ -431,7 +431,7 @@ class CodeEventLogger : public CodeEventListener {
private:
class NameBuffer;
virtual void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
virtual void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) = 0;
virtual void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) = 0;
@ -461,9 +461,9 @@ class ExternalCodeEventListener : public CodeEventListener {
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name name) override;
SharedFunctionInfo shared, Name name) override;
void CodeCreateEvent(LogEventsAndTags tag, AbstractCode code,
SharedFunctionInfo* shared, Name source, int line,
SharedFunctionInfo shared, Name source, int line,
int column) override;
void CodeCreateEvent(LogEventsAndTags tag, const wasm::WasmCode* code,
wasm::WasmName name) override;
@ -475,7 +475,7 @@ class ExternalCodeEventListener : public CodeEventListener {
void SharedFunctionInfoMoveEvent(Address from, Address to) override {}
void CodeMoveEvent(AbstractCode from, AbstractCode to) override {}
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
void CodeMovingGCEvent() override {}
void CodeDeoptEvent(Code code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) override {}

View File

@ -805,18 +805,6 @@ void HeapObject::VerifySmiField(int offset) {
CHECK(READ_FIELD(this, offset)->IsSmi());
}
void HeapObjectPtr::VerifyObjectField(Isolate* isolate, int offset) {
Object::VerifyPointer(isolate, READ_FIELD(this, offset));
}
void HeapObjectPtr::VerifyMaybeObjectField(Isolate* isolate, int offset) {
MaybeObject::VerifyMaybeObjectPointer(isolate, READ_WEAK_FIELD(this, offset));
}
void HeapObjectPtr::VerifySmiField(int offset) {
CHECK(READ_FIELD(this, offset)->IsSmi());
}
#endif
ReadOnlyRoots HeapObject::GetReadOnlyRoots() const {

View File

@ -774,7 +774,7 @@ void JSGeneratorObject::JSGeneratorObjectPrint(std::ostream& os) { // NOLINT
if (is_suspended()) os << " (suspended)";
if (is_suspended()) {
DisallowHeapAllocation no_gc;
SharedFunctionInfo* fun_info = function()->shared();
SharedFunctionInfo fun_info = function()->shared();
if (fun_info->HasSourceCode()) {
Script* script = Script::cast(fun_info->script());
int lin = script->GetLineNumber(source_position()) + 1;
@ -1507,7 +1507,7 @@ void SharedFunctionInfo::PrintSourceCode(std::ostream& os) {
}
void SharedFunctionInfo::SharedFunctionInfoPrint(std::ostream& os) { // NOLINT
HeapObject::PrintHeader(os, "SharedFunctionInfo");
PrintHeader(os, "SharedFunctionInfo");
os << "\n - name: ";
if (HasSharedName()) {
os << Brief(Name());

View File

@ -2965,7 +2965,7 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
}
}
accumulator->Add(" (sfi = %p)",
reinterpret_cast<void*>(function->shared()));
reinterpret_cast<void*>(function->shared().ptr()));
accumulator->Put('>');
break;
}
@ -3620,7 +3620,7 @@ void HeapObject::HeapObjectShortPrint(std::ostream& os) { // NOLINT
}
case SHARED_FUNCTION_INFO_TYPE: {
SharedFunctionInfo* shared = SharedFunctionInfo::cast(this);
SharedFunctionInfo shared = SharedFunctionInfo::cast(this);
std::unique_ptr<char[]> debug_name = shared->DebugName()->ToCString();
if (debug_name[0] != 0) {
os << "<SharedFunctionInfo " << debug_name.get() << ">";
@ -10872,7 +10872,7 @@ Handle<DeoptimizationData> DeoptimizationData::Empty(Isolate* isolate) {
isolate->factory()->empty_fixed_array());
}
SharedFunctionInfo* DeoptimizationData::GetInlinedFunction(int index) {
SharedFunctionInfo DeoptimizationData::GetInlinedFunction(int index) {
if (index == -1) {
return SharedFunctionInfo::cast(SharedFunctionInfo());
} else {
@ -13651,7 +13651,7 @@ int Script::GetEvalPosition() {
if (!has_eval_from_shared()) {
position = 0;
} else {
SharedFunctionInfo* shared = eval_from_shared();
SharedFunctionInfo shared = eval_from_shared();
position = shared->abstract_code()->SourcePosition(-position);
}
DCHECK_GE(position, 0);
@ -13693,7 +13693,8 @@ bool Script::IsUserJavaScript() { return type() == Script::TYPE_NORMAL; }
bool Script::ContainsAsmModule() {
DisallowHeapAllocation no_gc;
SharedFunctionInfo::ScriptIterator iter(this->GetIsolate(), this);
while (SharedFunctionInfo* info = iter.Next()) {
for (SharedFunctionInfo info = iter.Next(); !info.is_null();
info = iter.Next()) {
if (info->HasAsmWasmData()) return true;
}
return false;
@ -13924,7 +13925,7 @@ SharedFunctionInfo::ScriptIterator::ScriptIterator(
shared_function_infos_(shared_function_infos),
index_(0) {}
SharedFunctionInfo* SharedFunctionInfo::ScriptIterator::Next() {
SharedFunctionInfo SharedFunctionInfo::ScriptIterator::Next() {
while (index_ < shared_function_infos_->length()) {
MaybeObject raw = shared_function_infos_->Get(index_++);
HeapObject* heap_object;
@ -13934,7 +13935,7 @@ SharedFunctionInfo* SharedFunctionInfo::ScriptIterator::Next() {
}
return SharedFunctionInfo::cast(heap_object);
}
return nullptr;
return SharedFunctionInfo();
}
void SharedFunctionInfo::ScriptIterator::Reset(Script* script) {
@ -13947,14 +13948,14 @@ SharedFunctionInfo::GlobalIterator::GlobalIterator(Isolate* isolate)
noscript_sfi_iterator_(isolate->heap()->noscript_shared_function_infos()),
sfi_iterator_(isolate, script_iterator_.Next()) {}
SharedFunctionInfo* SharedFunctionInfo::GlobalIterator::Next() {
SharedFunctionInfo SharedFunctionInfo::GlobalIterator::Next() {
HeapObject* next = noscript_sfi_iterator_.Next();
if (next != nullptr) return SharedFunctionInfo::cast(next);
for (;;) {
next = sfi_iterator_.Next();
if (next != nullptr) return SharedFunctionInfo::cast(next);
Script* next_script = script_iterator_.Next();
if (next_script == nullptr) return nullptr;
if (next_script == nullptr) return SharedFunctionInfo();
sfi_iterator_.Reset(next_script);
}
}
@ -14147,9 +14148,9 @@ int SharedFunctionInfo::FindIndexInScript(Isolate* isolate) const {
SharedFunctionInfo::ScriptIterator iterator(
isolate, Handle<WeakFixedArray>(&shared_info_list));
for (SharedFunctionInfo* shared = iterator.Next(); shared != nullptr;
for (SharedFunctionInfo shared = iterator.Next(); !shared.is_null();
shared = iterator.Next()) {
if (shared == this) {
if (shared == *this) {
return iterator.CurrentIndex();
}
}
@ -14226,7 +14227,7 @@ bool JSFunction::CalculateInstanceSizeForDerivedClass(
// Output the source code without any allocation in the heap.
std::ostream& operator<<(std::ostream& os, const SourceCodeOf& v) {
const SharedFunctionInfo* s = v.value;
const SharedFunctionInfo s = v.value;
// For some native functions there is no source.
if (!s->HasSourceCode()) return os << "<No Source>";
@ -14265,7 +14266,7 @@ void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
// Code should be the lazy compilation stub or else interpreted.
DCHECK(abstract_code()->kind() == AbstractCode::INTERPRETED_FUNCTION ||
abstract_code()->kind() == AbstractCode::BUILTIN);
PROFILE(GetIsolate(), CodeDisableOptEvent(abstract_code(), this));
PROFILE(GetIsolate(), CodeDisableOptEvent(abstract_code(), *this));
if (FLAG_trace_opt) {
PrintF("[disabled optimization for ");
ShortPrint();
@ -14772,7 +14773,7 @@ bool Code::IsIsolateIndependent(Isolate* isolate) {
return is_process_independent;
}
bool Code::Inlines(SharedFunctionInfo* sfi) {
bool Code::Inlines(SharedFunctionInfo sfi) {
// We can only check for inlining for optimized code.
DCHECK(is_optimized_code());
DisallowHeapAllocation no_gc;
@ -16287,7 +16288,7 @@ class StringSharedKey : public HashTableKey {
return Hash() == other_hash;
}
FixedArray other_array = FixedArray::cast(other);
SharedFunctionInfo* shared = SharedFunctionInfo::cast(other_array->get(0));
SharedFunctionInfo shared = SharedFunctionInfo::cast(other_array->get(0));
if (shared != *shared_) return false;
int language_unchecked = Smi::ToInt(other_array->get(2));
DCHECK(is_valid_language_mode(language_unchecked));
@ -17793,7 +17794,7 @@ void CompilationCacheTable::Age() {
NoWriteBarrierSet(*this, value_index, count);
}
} else if (get(entry_index)->IsFixedArray()) {
SharedFunctionInfo* info = SharedFunctionInfo::cast(get(value_index));
SharedFunctionInfo info = SharedFunctionInfo::cast(get(value_index));
if (info->IsInterpreted() && info->GetBytecodeArray()->IsOld()) {
for (int i = 0; i < kEntrySize; i++) {
NoWriteBarrierSet(*this, entry_index + i, the_hole_value);

View File

@ -544,7 +544,7 @@ typedef Map MapArgType;
typedef Object* ObjectArgType;
typedef RegExpMatchInfo RegExpMatchInfoArgType;
typedef ScriptContextTable ScriptContextTableArgType;
typedef SharedFunctionInfo* SharedFunctionInfoArgType;
typedef SharedFunctionInfo SharedFunctionInfoArgType;
typedef SimpleNumberDictionary SimpleNumberDictionaryArgType;
typedef Smi SmiArgType;
typedef String StringArgType;

View File

@ -367,7 +367,7 @@ class Code : public HeapObjectPtr {
static inline bool IsWeakObjectInOptimizedCode(HeapObject* object);
// Return true if the function is inlined in the code.
bool Inlines(SharedFunctionInfo* sfi);
bool Inlines(SharedFunctionInfo sfi);
class OptimizedCodeIterator;
@ -873,7 +873,7 @@ class DeoptimizationData : public FixedArray {
// Returns the inlined function at the given position in LiteralArray, or the
// outer function if index == kNotInlinedIndex.
class SharedFunctionInfo* GetInlinedFunction(int index);
class SharedFunctionInfo GetInlinedFunction(int index);
// Allocates a DeoptimizationData.
static Handle<DeoptimizationData> New(Isolate* isolate, int deopt_entry_count,

View File

@ -32,7 +32,7 @@ uint32_t CompilationCacheShape::RegExpHash(String string, Smi flags) {
}
uint32_t CompilationCacheShape::StringSharedHash(String source,
SharedFunctionInfo* shared,
SharedFunctionInfo shared,
LanguageMode language_mode,
int position) {
uint32_t hash = source->Hash();
@ -58,7 +58,7 @@ uint32_t CompilationCacheShape::HashForObject(Isolate* isolate,
FixedArray val = FixedArray::cast(object);
if (val->map() == val->GetReadOnlyRoots().fixed_cow_array_map()) {
DCHECK_EQ(4, val->length());
SharedFunctionInfo* shared = SharedFunctionInfo::cast(val->get(0));
SharedFunctionInfo shared = SharedFunctionInfo::cast(val->get(0));
String source = String::cast(val->get(1));
int language_unchecked = Smi::ToInt(val->get(2));
DCHECK(is_valid_language_mode(language_unchecked));

View File

@ -7,6 +7,7 @@
#include "src/objects/hash-table.h"
#include "src/objects/js-regexp.h"
#include "src/objects/shared-function-info.h"
// Has to be the last include (doesn't have include guards):
#include "src/objects/object-macros.h"
@ -27,7 +28,7 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> {
static inline uint32_t RegExpHash(String string, Smi flags);
static inline uint32_t StringSharedHash(String source,
SharedFunctionInfo* shared,
SharedFunctionInfo shared,
LanguageMode language_mode,
int position);
@ -39,18 +40,18 @@ class CompilationCacheShape : public BaseShape<HashTableKey*> {
class InfoCellPair {
public:
InfoCellPair() : shared_(nullptr), feedback_cell_(nullptr) {}
InfoCellPair(SharedFunctionInfo* shared, FeedbackCell* feedback_cell)
InfoCellPair() : feedback_cell_(nullptr) {}
InfoCellPair(SharedFunctionInfo shared, FeedbackCell* feedback_cell)
: shared_(shared), feedback_cell_(feedback_cell) {}
FeedbackCell* feedback_cell() const { return feedback_cell_; }
SharedFunctionInfo* shared() const { return shared_; }
SharedFunctionInfo shared() const { return shared_; }
bool has_feedback_cell() const { return feedback_cell_ != nullptr; }
bool has_shared() const { return shared_ != nullptr; }
bool has_shared() const { return !shared_.is_null(); }
private:
SharedFunctionInfo* shared_;
SharedFunctionInfo shared_;
FeedbackCell* feedback_cell_;
};

View File

@ -26,7 +26,7 @@ CAST_ACCESSOR2(CoverageInfo)
CAST_ACCESSOR(BreakPoint)
SMI_ACCESSORS(DebugInfo, flags, kFlagsOffset)
ACCESSORS(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
ACCESSORS2(DebugInfo, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
SMI_ACCESSORS(DebugInfo, debugger_hints, kDebuggerHintsOffset)
ACCESSORS(DebugInfo, script, Object, kScriptOffset)
ACCESSORS(DebugInfo, original_bytecode_array, Object,

View File

@ -37,7 +37,7 @@ class DebugInfo : public Struct, public NeverReadOnlySpaceObject {
DECL_INT_ACCESSORS(flags)
// The shared function info for the source being debugged.
DECL_ACCESSORS(shared, SharedFunctionInfo)
DECL_ACCESSORS2(shared, SharedFunctionInfo)
// Bit field containing various information collected for debugging.
DECL_INT_ACCESSORS(debugger_hints)

View File

@ -179,6 +179,21 @@ MaybeObjectSlot HeapObjectPtr::RawMaybeWeakField(int byte_offset) const {
return MaybeObjectSlot(FIELD_ADDR(this, byte_offset));
}
#ifdef VERIFY_HEAP
void HeapObjectPtr::VerifyObjectField(Isolate* isolate, int offset) {
HeapObject::VerifyPointer(isolate, READ_FIELD(this, offset));
}
void HeapObjectPtr::VerifyMaybeObjectField(Isolate* isolate, int offset) {
MaybeObject::VerifyMaybeObjectPointer(isolate, READ_WEAK_FIELD(this, offset));
}
void HeapObjectPtr::VerifySmiField(int offset) {
CHECK(READ_FIELD(this, offset)->IsSmi());
}
#endif
Address HeapObjectPtr::GetFieldAddress(int field_offset) const {
return FIELD_ADDR(this, field_offset);
}

View File

@ -172,14 +172,11 @@ class HeapObjectPtr : public ObjectPtr {
void PrintHeader(std::ostream& os, const char* id); // NOLINT
#endif
void HeapObjectVerify(Isolate* isolate);
#ifdef VERIFY_HEAP
static void VerifyHeapPointer(Isolate* isolate, Object* p);
#endif
#ifdef VERIFY_HEAP
inline void VerifyObjectField(Isolate* isolate, int offset);
inline void VerifySmiField(int offset);
inline void VerifyMaybeObjectField(Isolate* isolate, int offset);
static void VerifyHeapPointer(Isolate* isolate, Object* p);
#endif
static const int kMapOffset = HeapObject::kMapOffset;

View File

@ -421,7 +421,7 @@ ACCESSORS(JSBoundFunction, bound_target_function, JSReceiver,
ACCESSORS(JSBoundFunction, bound_this, Object, kBoundThisOffset)
ACCESSORS2(JSBoundFunction, bound_arguments, FixedArray, kBoundArgumentsOffset)
ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
ACCESSORS2(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
ACCESSORS(JSFunction, feedback_cell, FeedbackCell, kFeedbackCellOffset)
ACCESSORS2(JSGlobalObject, native_context, Context, kNativeContextOffset)

View File

@ -902,7 +902,7 @@ class JSFunction : public JSObject {
// [shared]: The information about the function that
// can be shared by instances.
DECL_ACCESSORS(shared, SharedFunctionInfo)
DECL_ACCESSORS2(shared, SharedFunctionInfo)
static const int kLengthDescriptorIndex = 0;
static const int kNameDescriptorIndex = 1;

View File

@ -265,7 +265,7 @@ Object* Module::GetException() {
return exception();
}
SharedFunctionInfo* Module::GetSharedFunctionInfo() const {
SharedFunctionInfo Module::GetSharedFunctionInfo() const {
DisallowHeapAllocation no_alloc;
DCHECK_NE(status(), Module::kEvaluating);
DCHECK_NE(status(), Module::kEvaluated);

View File

@ -70,7 +70,7 @@ class Module : public Struct, public NeverReadOnlySpaceObject {
// The shared function info in case {status} is not kEvaluating, kEvaluated or
// kErrored.
SharedFunctionInfo* GetSharedFunctionInfo() const;
SharedFunctionInfo GetSharedFunctionInfo() const;
// The namespace object (or undefined).
DECL_ACCESSORS(module_namespace, HeapObject)

View File

@ -50,13 +50,13 @@ bool Script::has_eval_from_shared() const {
return eval_from_shared_or_wrapped_arguments()->IsSharedFunctionInfo();
}
void Script::set_eval_from_shared(SharedFunctionInfo* shared,
void Script::set_eval_from_shared(SharedFunctionInfo shared,
WriteBarrierMode mode) {
DCHECK(!is_wrapped());
set_eval_from_shared_or_wrapped_arguments(shared, mode);
}
SharedFunctionInfo* Script::eval_from_shared() const {
SharedFunctionInfo Script::eval_from_shared() const {
DCHECK(has_eval_from_shared());
return SharedFunctionInfo::cast(eval_from_shared_or_wrapped_arguments());
}

View File

@ -64,7 +64,7 @@ class Script : public Struct, public NeverReadOnlySpaceObject {
// [eval_from_shared]: for eval scripts the shared function info for the
// function from which eval was called.
DECL_ACCESSORS(eval_from_shared, SharedFunctionInfo)
DECL_ACCESSORS2(eval_from_shared, SharedFunctionInfo)
// [wrapped_arguments]: for the list of arguments in a wrapped script.
DECL_ACCESSORS2(wrapped_arguments, FixedArray)

View File

@ -78,7 +78,9 @@ ACCESSORS2(InterpreterData, bytecode_array, BytecodeArray, kBytecodeArrayOffset)
ACCESSORS2(InterpreterData, interpreter_trampoline, Code,
kInterpreterTrampolineOffset)
CAST_ACCESSOR(SharedFunctionInfo)
OBJECT_CONSTRUCTORS_IMPL(SharedFunctionInfo, HeapObjectPtr)
NEVER_READ_ONLY_SPACE_IMPL(SharedFunctionInfo)
CAST_ACCESSOR2(SharedFunctionInfo)
DEFINE_DEOPT_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
ACCESSORS(SharedFunctionInfo, name_or_scope_info, Object,

View File

@ -181,8 +181,9 @@ class InterpreterData : public Struct {
// SharedFunctionInfo describes the JSFunction information that can be
// shared by multiple instances of the function.
class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
class SharedFunctionInfo : public HeapObjectPtr {
public:
NEVER_READ_ONLY_SPACE
static constexpr ObjectPtr const kNoSharedNameSentinel = Smi::kZero;
// [name]: Returns shared name if it exists or an empty string otherwise.
@ -546,7 +547,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
ScriptIterator(Isolate* isolate, Script* script);
ScriptIterator(Isolate* isolate,
Handle<WeakFixedArray> shared_function_infos);
SharedFunctionInfo* Next();
SharedFunctionInfo Next();
int CurrentIndex() const { return index_ - 1; }
// Reset the iterator to run on |script|.
@ -563,7 +564,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
class GlobalIterator {
public:
explicit GlobalIterator(Isolate* isolate);
SharedFunctionInfo* Next();
SharedFunctionInfo Next();
private:
Script::Iterator script_iterator_;
@ -573,7 +574,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
DISALLOW_COPY_AND_ASSIGN(GlobalIterator);
};
DECL_CAST(SharedFunctionInfo)
DECL_CAST2(SharedFunctionInfo)
// Constants.
static const uint16_t kDontAdaptArgumentsSentinel = static_cast<uint16_t>(-1);
@ -679,14 +680,14 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
// FunctionLiteralId.
int FindIndexInScript(Isolate* isolate) const;
DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo);
OBJECT_CONSTRUCTORS(SharedFunctionInfo, HeapObjectPtr);
};
// Printing support.
struct SourceCodeOf {
explicit SourceCodeOf(SharedFunctionInfo* v, int max = -1)
explicit SourceCodeOf(SharedFunctionInfo v, int max = -1)
: value(v), max_length(max) {}
const SharedFunctionInfo* value;
const SharedFunctionInfo value;
int max_length;
};

View File

@ -114,7 +114,7 @@ bool FunctionTemplateInfo::instantiated() {
bool FunctionTemplateInfo::BreakAtEntry() {
Object* maybe_shared = shared_function_info();
if (maybe_shared->IsSharedFunctionInfo()) {
SharedFunctionInfo* shared = SharedFunctionInfo::cast(maybe_shared);
SharedFunctionInfo shared = SharedFunctionInfo::cast(maybe_shared);
return shared->BreakAtEntry();
}
return false;

View File

@ -196,7 +196,7 @@ uint64_t PerfJitLogger::GetTimestamp() {
}
void PerfJitLogger::LogRecordedBuffer(AbstractCode abstract_code,
SharedFunctionInfo* shared,
SharedFunctionInfo shared,
const char* name, int length) {
if (FLAG_perf_basic_prof_only_functions &&
(abstract_code->kind() != AbstractCode::INTERPRETED_FUNCTION &&
@ -214,7 +214,7 @@ void PerfJitLogger::LogRecordedBuffer(AbstractCode abstract_code,
DCHECK(code->raw_instruction_start() == code->address() + Code::kHeaderSize);
// Debug info has to be emitted first.
if (FLAG_perf_prof && shared != nullptr) {
if (FLAG_perf_prof && !shared.is_null()) {
// TODO(herhut): This currently breaks for js2wasm/wasm2js functions.
if (code->kind() != Code::JS_TO_WASM_FUNCTION &&
code->kind() != Code::WASM_TO_JS_FUNCTION) {
@ -322,7 +322,7 @@ SourcePositionInfo GetSourcePositionInfo(Handle<Code> code,
} // namespace
void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo* shared) {
void PerfJitLogger::LogWriteDebugInfo(Code code, SharedFunctionInfo shared) {
// Compute the entry count and get the name of the script.
uint32_t entry_count = 0;
for (SourcePositionTableIterator iterator(code->SourcePositionTable());

View File

@ -43,7 +43,7 @@ class PerfJitLogger : public CodeEventLogger {
void CodeMoveEvent(AbstractCode from, AbstractCode to) override;
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
private:
void OpenJitDumpFile();
@ -52,7 +52,7 @@ class PerfJitLogger : public CodeEventLogger {
void CloseMarkerFile(void* marker_address);
uint64_t GetTimestamp();
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) override;
void LogRecordedBuffer(const wasm::WasmCode* code, const char* name,
int length) override;
@ -70,7 +70,7 @@ class PerfJitLogger : public CodeEventLogger {
void LogWriteBytes(const char* bytes, int size);
void LogWriteHeader();
void LogWriteDebugInfo(Code code, SharedFunctionInfo* shared);
void LogWriteDebugInfo(Code code, SharedFunctionInfo shared);
void LogWriteUnwindingInfo(Code code);
static const uint32_t kElfMachIA32 = 3;
@ -125,11 +125,11 @@ class PerfJitLogger : public CodeEventLogger {
}
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {
SharedFunctionInfo shared) override {
UNIMPLEMENTED();
}
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo* shared,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo shared,
const char* name, int length) override {
UNIMPLEMENTED();
}

View File

@ -213,7 +213,7 @@ void AllocationTracker::AllocationEvent(Address addr, int size) {
JavaScriptFrameIterator it(isolate);
while (!it.done() && length < kMaxAllocationTraceLength) {
JavaScriptFrame* frame = it.frame();
SharedFunctionInfo* shared = frame->function()->shared();
SharedFunctionInfo shared = frame->function()->shared();
SnapshotObjectId id = ids_->FindOrAddEntry(
shared->address(), shared->Size(), false);
allocation_trace_buffer_[length++] = AddFunctionInfo(shared, id);
@ -237,8 +237,7 @@ static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) {
return ComputeUnseededHash(static_cast<uint32_t>(id));
}
unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared,
unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo shared,
SnapshotObjectId id) {
base::HashMap::Entry* entry = id_to_function_info_index_.LookupOrInsert(
reinterpret_cast<void*>(id), SnapshotObjectIdHash(id));
@ -264,7 +263,6 @@ unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared,
return static_cast<unsigned>(reinterpret_cast<intptr_t>((entry->value)));
}
unsigned AllocationTracker::functionInfoIndexForVMState(StateTag state) {
if (state != OTHER) return 0;
if (info_index_for_other_state_ == 0) {

View File

@ -120,7 +120,7 @@ class AllocationTracker {
AddressToTraceMap* address_to_trace() { return &address_to_trace_; }
private:
unsigned AddFunctionInfo(SharedFunctionInfo* info, SnapshotObjectId id);
unsigned AddFunctionInfo(SharedFunctionInfo info, SnapshotObjectId id);
unsigned functionInfoIndexForVMState(StateTag state);
class UnresolvedLocation {

View File

@ -547,7 +547,7 @@ void V8HeapExplorer::ExtractLocationForJSFunction(HeapEntry* entry,
HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object) {
if (object->IsJSFunction()) {
JSFunction* func = JSFunction::cast(object);
SharedFunctionInfo* shared = func->shared();
SharedFunctionInfo shared = func->shared();
const char* name = names_->GetName(shared->Name());
return AddEntry(object, HeapEntry::kClosure, name);
} else if (object->IsJSBoundFunction()) {
@ -820,7 +820,7 @@ void V8HeapExplorer::ExtractJSObjectReferences(HeapEntry* entry,
}
}
}
SharedFunctionInfo* shared_info = js_fun->shared();
SharedFunctionInfo shared_info = js_fun->shared();
TagObject(js_fun->feedback_cell(), "(function feedback cell)");
SetInternalReference(entry, "feedback_cell", js_fun->feedback_cell(),
JSFunction::kFeedbackCellOffset);
@ -1047,7 +1047,7 @@ void V8HeapExplorer::ExtractMapReferences(HeapEntry* entry, Map map) {
}
void V8HeapExplorer::ExtractSharedFunctionInfoReferences(
HeapEntry* entry, SharedFunctionInfo* shared) {
HeapEntry* entry, SharedFunctionInfo shared) {
String shared_name = shared->DebugName();
const char* name = nullptr;
if (shared_name != ReadOnlyRoots(heap_).empty_string()) {

View File

@ -358,7 +358,7 @@ class V8HeapExplorer : public HeapEntriesAllocator {
void ExtractContextReferences(HeapEntry* entry, Context context);
void ExtractMapReferences(HeapEntry* entry, Map map);
void ExtractSharedFunctionInfoReferences(HeapEntry* entry,
SharedFunctionInfo* shared);
SharedFunctionInfo shared);
void ExtractScriptReferences(HeapEntry* entry, Script* script);
void ExtractAccessorInfoReferences(HeapEntry* entry,
AccessorInfo* accessor_info);

View File

@ -142,7 +142,7 @@ void CodeEntry::set_deopt_info(
rare_data->deopt_inlined_frames_ = std::move(inlined_frames);
}
void CodeEntry::FillFunctionInfo(SharedFunctionInfo* shared) {
void CodeEntry::FillFunctionInfo(SharedFunctionInfo shared) {
if (!shared->script()->IsScript()) return;
Script* script = Script::cast(shared->script());
set_script_id(script->id());

View File

@ -91,7 +91,7 @@ class CodeEntry {
void mark_used() { bit_field_ = UsedField::update(bit_field_, true); }
bool used() const { return UsedField::decode(bit_field_); }
void FillFunctionInfo(SharedFunctionInfo* shared);
void FillFunctionInfo(SharedFunctionInfo shared);
void SetBuiltinId(Builtins::Name id);
Builtins::Name builtin_id() const {

View File

@ -60,7 +60,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code,
SharedFunctionInfo* shared,
SharedFunctionInfo shared,
Name script_name) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
@ -78,7 +78,7 @@ void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
void ProfilerListener::CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode abstract_code,
SharedFunctionInfo* shared,
SharedFunctionInfo shared,
Name script_name, int line, int column) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_CREATION);
CodeCreateEventRecord* rec = &evt_rec.CodeCreateEventRecord_;
@ -131,7 +131,7 @@ void ProfilerListener::CodeMoveEvent(AbstractCode from, AbstractCode to) {
}
void ProfilerListener::CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) {
SharedFunctionInfo shared) {
CodeEventsContainer evt_rec(CodeEventRecord::CODE_DISABLE_OPT);
CodeDisableOptEventRecord* rec = &evt_rec.CodeDisableOptEventRecord_;
rec->instruction_start = code->InstructionStart();
@ -188,7 +188,7 @@ void ProfilerListener::SetterCallbackEvent(Name name, Address entry_point) {
DispatchCodeEvent(evt_rec);
}
Name ProfilerListener::InferScriptName(Name name, SharedFunctionInfo* info) {
Name ProfilerListener::InferScriptName(Name name, SharedFunctionInfo info) {
if (name->IsString() && String::cast(name)->length()) return name;
if (!info->script()->IsScript()) return name;
Object* source_url = Script::cast(info->script())->source_url();
@ -226,7 +226,7 @@ void ProfilerListener::RecordInliningInfo(CodeEntry* entry,
it.Next(); // Skip height
it.Next(); // Skip return value offset
it.Next(); // Skip return value count
SharedFunctionInfo* shared_info = SharedFunctionInfo::cast(
SharedFunctionInfo shared_info = SharedFunctionInfo::cast(
deopt_input_data->LiteralArray()->get(shared_info_id));
if (!depth++) continue; // Skip the current function itself.

View File

@ -34,10 +34,10 @@ class ProfilerListener : public CodeEventListener {
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, Name name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name script_name) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
AbstractCode code, SharedFunctionInfo* shared,
AbstractCode code, SharedFunctionInfo shared,
Name script_name, int line, int column) override;
void CodeCreateEvent(CodeEventListener::LogEventsAndTags tag,
const wasm::WasmCode* code,
@ -46,7 +46,7 @@ class ProfilerListener : public CodeEventListener {
void CodeMovingGCEvent() override {}
void CodeMoveEvent(AbstractCode from, AbstractCode to) override;
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override;
SharedFunctionInfo shared) override;
void CodeDeoptEvent(Code code, DeoptimizeKind kind, Address pc,
int fp_to_sp_delta) override;
void GetterCallbackEvent(Name name, Address entry_point) override;
@ -78,7 +78,7 @@ class ProfilerListener : public CodeEventListener {
private:
void RecordInliningInfo(CodeEntry* entry, AbstractCode abstract_code);
void AttachDeoptInlinedFrames(Code code, CodeDeoptEventRecord* rec);
Name InferScriptName(Name name, SharedFunctionInfo* info);
Name InferScriptName(Name name, SharedFunctionInfo info);
V8_INLINE void DispatchCodeEvent(const CodeEventsContainer& evt_rec) {
observer_->CodeEventHandler(evt_rec);
}

View File

@ -149,7 +149,7 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::FindOrAddChildNode(
SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
AllocationNode* node = &profile_root_;
std::vector<SharedFunctionInfo*> stack;
std::vector<SharedFunctionInfo> stack;
JavaScriptFrameIterator it(isolate_);
int frames_captured = 0;
bool found_arguments_marker_frames = false;
@ -161,7 +161,7 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
// in the top frames of the stack). The allocations made in this
// sensitive moment belong to the formerly optimized frame anyway.
if (frame->unchecked_function()->IsJSFunction()) {
SharedFunctionInfo* shared = frame->function()->shared();
SharedFunctionInfo shared = frame->function()->shared();
stack.push_back(shared);
frames_captured++;
} else {
@ -204,7 +204,7 @@ SamplingHeapProfiler::AllocationNode* SamplingHeapProfiler::AddStack() {
// We need to process the stack in reverse order as the top of the stack is
// the first element in the list.
for (auto it = stack.rbegin(); it != stack.rend(); ++it) {
SharedFunctionInfo* shared = *it;
SharedFunctionInfo shared = *it;
const char* name = this->names()->GetName(shared->DebugName());
int script_id = v8::UnboundScript::kNoScriptId;
if (shared->script()->IsScript()) {

View File

@ -115,7 +115,7 @@ void RuntimeProfiler::Optimize(JSFunction* function,
void RuntimeProfiler::AttemptOnStackReplacement(InterpretedFrame* frame,
int loop_nesting_levels) {
JSFunction* function = frame->function();
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
if (!FLAG_use_osr || !function->shared()->IsUserJavaScript()) {
return;
}

View File

@ -65,7 +65,7 @@ RUNTIME_FUNCTION_RETURN_PAIR(Runtime_DebugBreakOnBytecode) {
DCHECK(it.frame()->is_interpreted());
InterpretedFrame* interpreted_frame =
reinterpret_cast<InterpretedFrame*>(it.frame());
SharedFunctionInfo* shared = interpreted_frame->function()->shared();
SharedFunctionInfo shared = interpreted_frame->function()->shared();
BytecodeArray bytecode_array = shared->GetBytecodeArray();
int bytecode_offset = interpreted_frame->GetBytecodeOffset();
Bytecode bytecode = Bytecodes::FromByte(bytecode_array->get(bytecode_offset));
@ -746,7 +746,7 @@ RUNTIME_FUNCTION(Runtime_IncBlockCounter) {
// coverage collection mode, which triggers deletion of all coverage infos in
// order to avoid memory leaks.
SharedFunctionInfo* shared = function->shared();
SharedFunctionInfo shared = function->shared();
if (shared->HasCoverageInfo()) {
CoverageInfo coverage_info = shared->GetCoverageInfo();
coverage_info->IncrementBlockCount(coverage_array_slot_index);

View File

@ -137,7 +137,7 @@ RUNTIME_FUNCTION(Runtime_AsyncGeneratorHasCatchHandlerForPC) {
// not reach a catch handler.
if (state < 1) return ReadOnlyRoots(isolate).false_value();
SharedFunctionInfo* shared = generator->function()->shared();
SharedFunctionInfo shared = generator->function()->shared();
DCHECK(shared->HasBytecodeArray());
HandlerTable handler_table(shared->GetBytecodeArray());

View File

@ -1040,7 +1040,7 @@ inline void TrySetNative(Handle<Object> maybe_func) {
inline void TrySetNativeAndLength(Handle<Object> maybe_func, int length) {
if (!maybe_func->IsJSFunction()) return;
SharedFunctionInfo* shared = JSFunction::cast(*maybe_func)->shared();
SharedFunctionInfo shared = JSFunction::cast(*maybe_func)->shared();
shared->set_native(true);
if (length >= 0) {
shared->set_length(length);

View File

@ -348,7 +348,7 @@ std::unique_ptr<Handle<Object>[]> GetCallerArguments(Isolate* isolate,
// Find frame containing arguments passed to the caller.
JavaScriptFrameIterator it(isolate);
JavaScriptFrame* frame = it.frame();
std::vector<SharedFunctionInfo*> functions;
std::vector<SharedFunctionInfo> functions;
frame->GetFunctions(&functions);
if (functions.size() > 1) {
int inlined_jsframe_index = static_cast<int>(functions.size()) - 1;

View File

@ -181,7 +181,7 @@ void CodeSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
}
if (obj->IsSharedFunctionInfo()) {
SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
SharedFunctionInfo sfi = SharedFunctionInfo::cast(obj);
// TODO(7110): Enable serializing of Asm modules once the AsmWasmData
// is context independent.
DCHECK(!sfi->IsApiFunction() && !sfi->HasAsmWasmData());

View File

@ -33,7 +33,7 @@ class CodeAddressMap : public CodeEventLogger {
}
void CodeDisableOptEvent(AbstractCode code,
SharedFunctionInfo* shared) override {}
SharedFunctionInfo shared) override {}
const char* Lookup(Address address) {
return address_to_name_map_.Lookup(address);
@ -114,7 +114,7 @@ class CodeAddressMap : public CodeEventLogger {
DISALLOW_COPY_AND_ASSIGN(NameMap);
};
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo*,
void LogRecordedBuffer(AbstractCode code, SharedFunctionInfo,
const char* name, int length) override {
address_to_name_map_.Insert(code->address(), name, length);
}

View File

@ -87,7 +87,7 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
ReadOnlyRoots(isolate()).uninitialized_symbol());
} else if (obj->IsSharedFunctionInfo()) {
// Clear inferred name for native functions.
SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
SharedFunctionInfo shared = SharedFunctionInfo::cast(obj);
if (!shared->IsSubjectToDebugging() && shared->HasUncompiledData()) {
shared->uncompiled_data()->set_inferred_name(
ReadOnlyRoots(isolate()).empty_string());

View File

@ -76,7 +76,7 @@ std::vector<SourcePositionInfo> SourcePosition::InliningStack(
}
void SourcePosition::Print(std::ostream& out,
SharedFunctionInfo* function) const {
SharedFunctionInfo function) const {
Script::PositionInfo pos;
Object* source_name = nullptr;
if (function->script()->IsScript()) {
@ -104,7 +104,7 @@ void SourcePosition::Print(std::ostream& out, Code code) const {
DeoptimizationData deopt_data =
DeoptimizationData::cast(code->deoptimization_data());
if (!isInlined()) {
SharedFunctionInfo* function(
SharedFunctionInfo function(
SharedFunctionInfo::cast(deopt_data->SharedFunctionInfo()));
Print(out, function);
} else {
@ -112,7 +112,7 @@ void SourcePosition::Print(std::ostream& out, Code code) const {
if (inl.inlined_function_id == -1) {
out << *this;
} else {
SharedFunctionInfo* function =
SharedFunctionInfo function =
deopt_data->GetInlinedFunction(inl.inlined_function_id);
Print(out, function);
}

View File

@ -76,7 +76,7 @@ class SourcePosition final {
}
private:
void Print(std::ostream& out, SharedFunctionInfo* function) const;
void Print(std::ostream& out, SharedFunctionInfo function) const;
// InliningId is in the high bits for better compression in
// SourcePositionTable.

View File

@ -5147,7 +5147,7 @@ TEST(SharedFunctionInfoIterator) {
{
SharedFunctionInfo::GlobalIterator iterator(isolate);
while (iterator.Next()) sfi_count--;
while (!iterator.Next().is_null()) sfi_count--;
}
CHECK_EQ(0, sfi_count);

View File

@ -33,7 +33,8 @@ void GetTopLevelFunctionInfo(
SharedFunctionInfo::ScriptIterator iterator(
toplevel_fn->GetIsolate(), Script::cast(toplevel_fn->shared()->script()));
while (SharedFunctionInfo* shared = iterator.Next()) {
for (SharedFunctionInfo shared = iterator.Next(); !shared.is_null();
shared = iterator.Next()) {
std::unique_ptr<char[]> name = String::cast(shared->Name())->ToCString();
is_compiled->insert(std::make_pair(name.get(), shared->is_compiled()));
}

View File

@ -1136,7 +1136,7 @@ static void TickLines(bool optimize) {
i::Handle<i::JSFunction> func = i::Handle<i::JSFunction>::cast(
v8::Utils::OpenHandle(*GetFunction(env.local(), func_name)));
CHECK(func->shared());
CHECK(!func->shared().is_null());
CHECK(!func->shared()->abstract_code().is_null());
CHECK(!optimize || func->IsOptimized() ||
!CcTest::i_isolate()->use_optimizer());

View File

@ -535,10 +535,10 @@ TEST(Issue539892) {
void CodeMoveEvent(i::AbstractCode from, i::AbstractCode to) override {}
void CodeDisableOptEvent(i::AbstractCode code,
i::SharedFunctionInfo* shared) override {}
i::SharedFunctionInfo shared) override {}
private:
void LogRecordedBuffer(i::AbstractCode code, i::SharedFunctionInfo* shared,
void LogRecordedBuffer(i::AbstractCode code, i::SharedFunctionInfo shared,
const char* name, int length) override {}
void LogRecordedBuffer(const i::wasm::WasmCode* code, const char* name,
int length) override {}

View File

@ -2124,7 +2124,8 @@ void CheckDeserializedFlag(v8::Local<v8::UnboundScript> script) {
i::Handle<i::SharedFunctionInfo> sfi = v8::Utils::OpenHandle(*script);
i::SharedFunctionInfo::ScriptIterator iterator(sfi->GetIsolate(),
Script::cast(sfi->script()));
while (SharedFunctionInfo* next = iterator.Next()) {
for (SharedFunctionInfo next = iterator.Next(); !next.is_null();
next = iterator.Next()) {
CHECK_EQ(next->is_compiled(), next->deserialized());
}
}