Commit 1cc57350 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Cleanup] Move some inlined SFI functions to .cc and export for tests.

Moves some functions that used to be simple, but now do more complex logic
out of the inlined headers into .cc to avoid having to export all the
functions they depend on as V8_PRIVATE_EXPORT for tests. Also mark them
as V8_PRIVATE_EXPORT for tests along with a couple in ast.h

BUG=v8:8041

Change-Id: I6e94ca160cd3d84a0d1b099167a7b9862f08b122
Reviewed-on: https://chromium-review.googlesource.com/1216642Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarAdam Klein <adamk@chromium.org>
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55772}
parent 589906ab
......@@ -298,9 +298,9 @@ class AstValueFactory {
}
const AstRawString* GetString(Handle<String> literal);
V8_EXPORT_PRIVATE AstConsString* NewConsString();
AstConsString* NewConsString(const AstRawString* str);
AstConsString* NewConsString(const AstRawString* str1,
const AstRawString* str2);
V8_EXPORT_PRIVATE AstConsString* NewConsString(const AstRawString* str);
V8_EXPORT_PRIVATE AstConsString* NewConsString(const AstRawString* str1,
const AstRawString* str2);
V8_EXPORT_PRIVATE void Internalize(Isolate* isolate);
......
......@@ -2318,7 +2318,7 @@ class FunctionLiteral final : public Expression {
// - (function() { ... })();
// - var x = function() { ... }();
bool ShouldEagerCompile() const;
void SetShouldEagerCompile();
V8_EXPORT_PRIVATE void SetShouldEagerCompile();
FunctionType function_type() const {
return FunctionTypeBits::decode(bit_field_);
......
......@@ -14350,6 +14350,75 @@ void SharedFunctionInfo::SetFunctionTokenPosition(int function_token_position,
set_raw_function_token_offset(offset);
}
int SharedFunctionInfo::StartPosition() const {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
return info->StartPosition();
}
} else if (HasUncompiledData()) {
// Works with or without scope.
return uncompiled_data()->start_position();
} else if (IsApiFunction() || HasBuiltinId()) {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
return kNoSourcePosition;
}
int SharedFunctionInfo::EndPosition() const {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
return info->EndPosition();
}
} else if (HasUncompiledData()) {
// Works with or without scope.
return uncompiled_data()->end_position();
} else if (IsApiFunction() || HasBuiltinId()) {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
return kNoSourcePosition;
}
int SharedFunctionInfo::FunctionLiteralId(Isolate* isolate) const {
// Fast path for the common case when the SFI is uncompiled and so the
// function literal id is already in the uncompiled data.
if (HasUncompiledData()) {
int id = uncompiled_data()->function_literal_id();
// Make sure the id is what we should have found with the slow path.
DCHECK_EQ(id, FindIndexInScript(isolate));
return id;
}
// Otherwise, search for the function in the SFI's script's function list,
// and return its index in that list.e
return FindIndexInScript(isolate);
}
void SharedFunctionInfo::SetPosition(int start_position, int end_position) {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
info->SetPositionInfo(start_position, end_position);
}
} else if (HasUncompiledData()) {
if (HasUncompiledDataWithPreParsedScope()) {
// Clear out preparsed scope data, since the position setter invalidates
// any scope data.
ClearPreParsedScopeData();
}
uncompiled_data()->set_start_position(start_position);
uncompiled_data()->set_end_position(end_position);
} else {
UNREACHABLE();
}
}
void Map::StartInobjectSlackTracking() {
DCHECK(!IsInobjectSlackTrackingInProgress());
if (UnusedPropertyFields() == 0) return;
......
......@@ -282,60 +282,6 @@ void SharedFunctionInfo::DontAdaptArguments() {
set_internal_formal_parameter_count(kDontAdaptArgumentsSentinel);
}
int SharedFunctionInfo::StartPosition() const {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
return info->StartPosition();
}
} else if (HasUncompiledData()) {
// Works with or without scope.
return uncompiled_data()->start_position();
} else if (IsApiFunction() || HasBuiltinId()) {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
return kNoSourcePosition;
}
int SharedFunctionInfo::EndPosition() const {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
return info->EndPosition();
}
} else if (HasUncompiledData()) {
// Works with or without scope.
return uncompiled_data()->end_position();
} else if (IsApiFunction() || HasBuiltinId()) {
DCHECK_IMPLIES(HasBuiltinId(), builtin_id() != Builtins::kCompileLazy);
return 0;
}
return kNoSourcePosition;
}
void SharedFunctionInfo::SetPosition(int start_position, int end_position) {
Object* maybe_scope_info = name_or_scope_info();
if (maybe_scope_info->IsScopeInfo()) {
ScopeInfo* info = ScopeInfo::cast(maybe_scope_info);
if (info->HasPositionInfo()) {
info->SetPositionInfo(start_position, end_position);
}
} else if (HasUncompiledData()) {
if (HasUncompiledDataWithPreParsedScope()) {
// Clear out preparsed scope data, since the position setter invalidates
// any scope data.
ClearPreParsedScopeData();
}
uncompiled_data()->set_start_position(start_position);
uncompiled_data()->set_end_position(end_position);
} else {
UNREACHABLE();
}
}
bool SharedFunctionInfo::IsInterpreted() const { return HasBytecodeArray(); }
ScopeInfo* SharedFunctionInfo::scope_info() const {
......@@ -613,21 +559,6 @@ bool SharedFunctionInfo::HasWasmExportedFunctionData() const {
return function_data()->IsWasmExportedFunctionData();
}
int SharedFunctionInfo::FunctionLiteralId(Isolate* isolate) const {
// Fast path for the common case when the SFI is uncompiled and so the
// function literal id is already in the uncompiled data.
if (HasUncompiledData()) {
int id = uncompiled_data()->function_literal_id();
// Make sure the id is what we should have found with the slow path.
DCHECK_EQ(id, FindIndexInScript(isolate));
return id;
}
// Otherwise, search for the function in the SFI's script's function list,
// and return its index in that list.e
return FindIndexInScript(isolate);
}
Object* SharedFunctionInfo::script() const {
Object* maybe_script = script_or_debug_info();
if (maybe_script->IsDebugInfo()) {
......
......@@ -230,14 +230,14 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
DECL_ACCESSORS(scope_info, ScopeInfo)
// End position of this function in the script source.
inline int EndPosition() const;
V8_EXPORT_PRIVATE int EndPosition() const;
// Start position of this function in the script source.
inline int StartPosition() const;
V8_EXPORT_PRIVATE int StartPosition() const;
// Set the start and end position of this function in the script source.
// Updates the scope info if available.
inline void SetPosition(int start_position, int end_position);
V8_EXPORT_PRIVATE void SetPosition(int start_position, int end_position);
// [outer scope info | feedback metadata] Shared storage for outer scope info
// (on uncompiled functions) and feedback metadata (on compiled functions).
......@@ -358,7 +358,7 @@ class SharedFunctionInfo : public HeapObject, public NeverReadOnlySpaceObject {
inline String* inferred_name();
// Get the function literal id associated with this function, for parsing.
inline int FunctionLiteralId(Isolate* isolate) const;
V8_EXPORT_PRIVATE int FunctionLiteralId(Isolate* isolate) const;
// Break infos are contained in DebugInfo, this is a convenience method
// to simplify access.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment