Commit 6bdb9705 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter]: Move builtin-id from function_data to function_identifier.

Functions with builtin ids can be compiled with Ignition, so it is no longer
an option to overlap the bytecode_array field with the builtin id on
the SharedFunctionInfo object. Instead overlap it with the
inferred_name, which is only used for debug and so shouldn't be required
for functions with builtin ids. This result in the inferred_name field
being renamed to function_identifier, and adding typed accessors for
inferred_name and builtin_function_id.

This is required to build the snapshot with --no-lazy.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1801023002

Cr-Commit-Position: refs/heads/master@{#34867}
parent 992ae64d
......@@ -785,16 +785,18 @@ static bool CompileUnoptimizedCode(CompilationInfo* info) {
return true;
}
static bool UseIgnition(CompilationInfo* info) {
// Cannot use Ignition when the {function_data} is already used.
if (info->has_shared_info() && info->shared_info()->HasBuiltinFunctionId()) {
// TODO(4681): Generator functions are not yet supported.
if ((info->has_shared_info() && info->shared_info()->is_generator()) ||
(info->has_literal() && IsGeneratorFunction(info->literal()->kind()))) {
return false;
}
// TODO(4681): Generators are not yet supported.
if ((info->has_shared_info() && info->shared_info()->is_generator()) ||
(info->has_literal() && IsGeneratorFunction(info->literal()->kind()))) {
// TODO(4681): Resuming a suspended frame is not supported.
if (info->has_shared_info() && info->shared_info()->HasBuiltinFunctionId() &&
(info->shared_info()->builtin_function_id() == kGeneratorObjectNext ||
info->shared_info()->builtin_function_id() == kGeneratorObjectReturn ||
info->shared_info()->builtin_function_id() == kGeneratorObjectThrow)) {
return false;
}
......
......@@ -2107,7 +2107,7 @@ Handle<SharedFunctionInfo> Factory::NewSharedFunctionInfo(
share->set_function_data(*undefined_value(), SKIP_WRITE_BARRIER);
share->set_script(*undefined_value(), SKIP_WRITE_BARRIER);
share->set_debug_info(DebugInfo::uninitialized(), SKIP_WRITE_BARRIER);
share->set_inferred_name(*empty_string(), SKIP_WRITE_BARRIER);
share->set_function_identifier(*undefined_value(), SKIP_WRITE_BARRIER);
StaticFeedbackVectorSpec empty_spec;
Handle<TypeFeedbackMetadata> feedback_metadata =
TypeFeedbackMetadata::New(isolate(), &empty_spec);
......
......@@ -5589,8 +5589,8 @@ ACCESSORS(SharedFunctionInfo, instance_class_name, Object,
ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
ACCESSORS(SharedFunctionInfo, script, Object, kScriptOffset)
ACCESSORS(SharedFunctionInfo, debug_info, Object, kDebugInfoOffset)
ACCESSORS(SharedFunctionInfo, inferred_name, String, kInferredNameOffset)
ACCESSORS(SharedFunctionInfo, function_identifier, Object,
kFunctionIdentifierOffset)
SMI_ACCESSORS(FunctionTemplateInfo, length, kLengthOffset)
BOOL_ACCESSORS(FunctionTemplateInfo, flag, hidden_prototype,
......@@ -5923,21 +5923,6 @@ void SharedFunctionInfo::set_api_func_data(FunctionTemplateInfo* data) {
set_function_data(data);
}
bool SharedFunctionInfo::HasBuiltinFunctionId() {
return function_data()->IsSmi();
}
BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
DCHECK(HasBuiltinFunctionId());
return static_cast<BuiltinFunctionId>(Smi::cast(function_data())->value());
}
void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
DCHECK(function_data()->IsUndefined() || HasBuiltinFunctionId());
set_function_data(Smi::FromInt(id));
}
bool SharedFunctionInfo::HasBytecodeArray() {
return function_data()->IsBytecodeArray();
}
......@@ -5958,6 +5943,37 @@ void SharedFunctionInfo::ClearBytecodeArray() {
set_function_data(GetHeap()->undefined_value());
}
bool SharedFunctionInfo::HasBuiltinFunctionId() {
return function_identifier()->IsSmi();
}
BuiltinFunctionId SharedFunctionInfo::builtin_function_id() {
DCHECK(HasBuiltinFunctionId());
return static_cast<BuiltinFunctionId>(
Smi::cast(function_identifier())->value());
}
void SharedFunctionInfo::set_builtin_function_id(BuiltinFunctionId id) {
set_function_identifier(Smi::FromInt(id));
}
bool SharedFunctionInfo::HasInferredName() {
return function_identifier()->IsString();
}
String* SharedFunctionInfo::inferred_name() {
if (HasInferredName()) {
return String::cast(function_identifier());
}
DCHECK(function_identifier()->IsUndefined() || HasBuiltinFunctionId());
return GetIsolate()->heap()->empty_string();
}
void SharedFunctionInfo::set_inferred_name(String* inferred_name) {
DCHECK(function_identifier()->IsUndefined() || HasInferredName());
set_function_identifier(inferred_name);
}
int SharedFunctionInfo::ic_age() {
return ICAgeBits::decode(counters());
}
......
......@@ -6767,24 +6767,35 @@ class SharedFunctionInfo: public HeapObject {
// [function data]: This field holds some additional data for function.
// Currently it has one of:
// - a FunctionTemplateInfo to make benefit the API [IsApiFunction()].
// - a Smi identifying a builtin function [HasBuiltinFunctionId()].
// - a BytecodeArray for the interpreter [HasBytecodeArray()].
// In the long run we don't want all functions to have this field but
// we can fix that when we have a better model for storing hidden data
// on objects.
DECL_ACCESSORS(function_data, Object)
inline bool IsApiFunction();
inline FunctionTemplateInfo* get_api_func_data();
inline void set_api_func_data(FunctionTemplateInfo* data);
inline bool HasBuiltinFunctionId();
inline BuiltinFunctionId builtin_function_id();
inline void set_builtin_function_id(BuiltinFunctionId id);
inline bool HasBytecodeArray();
inline BytecodeArray* bytecode_array();
inline void set_bytecode_array(BytecodeArray* bytecode);
inline void ClearBytecodeArray();
// [function identifier]: This field holds an additional identifier for the
// function.
// - a Smi identifying a builtin function [HasBuiltinFunctionId()].
// - a String identifying the function's inferred name [HasInferredName()].
// The inferred_name is inferred from variable or property
// assignment of this function. It is used to facilitate debugging and
// profiling of JavaScript code written in OO style, where almost
// all functions are anonymous but are assigned to object
// properties.
DECL_ACCESSORS(function_identifier, Object)
inline bool HasBuiltinFunctionId();
inline BuiltinFunctionId builtin_function_id();
inline void set_builtin_function_id(BuiltinFunctionId id);
inline bool HasInferredName();
inline String* inferred_name();
inline void set_inferred_name(String* inferred_name);
// [script info]: Script from which the function originates.
DECL_ACCESSORS(script, Object)
......@@ -6810,13 +6821,6 @@ class SharedFunctionInfo: public HeapObject {
// [debug info]: Debug information.
DECL_ACCESSORS(debug_info, Object)
// [inferred name]: Name inferred from variable or property
// assignment of this function. Used to facilitate debugging and
// profiling of JavaScript code written in OO style, where almost
// all functions are anonymous but are assigned to object
// properties.
DECL_ACCESSORS(inferred_name, String)
// The function's name if it is non-empty, otherwise the inferred name.
String* DebugName();
......@@ -7056,9 +7060,9 @@ class SharedFunctionInfo: public HeapObject {
kInstanceClassNameOffset + kPointerSize;
static const int kScriptOffset = kFunctionDataOffset + kPointerSize;
static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
static const int kFunctionIdentifierOffset = kDebugInfoOffset + kPointerSize;
static const int kFeedbackVectorOffset =
kInferredNameOffset + kPointerSize;
kFunctionIdentifierOffset + kPointerSize;
#if TRACE_MAPS
static const int kUniqueIdOffset = kFeedbackVectorOffset + kPointerSize;
static const int kLastPointerFieldOffset = kUniqueIdOffset;
......
......@@ -1383,9 +1383,9 @@ void V8HeapExplorer::ExtractSharedFunctionInfoReferences(
SetInternalReference(obj, entry,
"debug_info", shared->debug_info(),
SharedFunctionInfo::kDebugInfoOffset);
SetInternalReference(obj, entry,
"inferred_name", shared->inferred_name(),
SharedFunctionInfo::kInferredNameOffset);
SetInternalReference(obj, entry, "function_identifier",
shared->function_identifier(),
SharedFunctionInfo::kFunctionIdentifierOffset);
SetInternalReference(obj, entry,
"optimized_code_map", shared->optimized_code_map(),
SharedFunctionInfo::kOptimizedCodeMapOffset);
......
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