Commit aff24a25 authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[Compile] Add an is_iife bit to SharedFunctionInfo and propagate to lazy compile.

If a function is classed as an IIFE it will be have different bytecode generated
to reduce feedback vector overhead for run-once code. As a result, we need to retain
this information if we are going to lazily compile the bytecode later in order to
get the same result. This is necessary for lazy bytecode flushing and lazy source
positions, both of which need to recompile functions which were previously compiled.

BUG=v8:8395,v8:8510

Change-Id: Ib898868102610216315faa20c9da682f6c523390
Reviewed-on: https://chromium-review.googlesource.com/c/1417636
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarToon Verwaest <verwaest@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58921}
parent b07e02ef
......@@ -406,6 +406,7 @@ void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal,
}
shared_info->set_has_duplicate_parameters(
literal->has_duplicate_parameters());
shared_info->set_is_iife(literal->is_iife());
shared_info->SetExpectedNofPropertiesFromEstimate(literal);
if (literal->dont_optimize_reason() != BailoutReason::kNoReason) {
shared_info->DisableOptimization(literal->dont_optimize_reason());
......
......@@ -222,6 +222,8 @@ BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_named_expression,
SharedFunctionInfo::IsNamedExpressionBit)
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_toplevel,
SharedFunctionInfo::IsTopLevelBit)
BIT_FIELD_ACCESSORS(SharedFunctionInfo, flags, is_iife,
SharedFunctionInfo::IsIIFEBit)
bool SharedFunctionInfo::optimization_disabled() const {
return disable_optimization_reason() != BailoutReason::kNoReason;
......
......@@ -488,6 +488,10 @@ class SharedFunctionInfo : public HeapObject {
// which does not change this flag).
DECL_BOOLEAN_ACCESSORS(is_anonymous_expression)
// Indicates that the function represented by the shared function info was
// classed as an immediately invoked function execution (IIFE) function.
DECL_BOOLEAN_ACCESSORS(is_iife)
// Indicates that the function has been reported for binary code coverage.
DECL_BOOLEAN_ACCESSORS(has_reported_binary_coverage)
......@@ -695,7 +699,8 @@ class SharedFunctionInfo : public HeapObject {
V(NameShouldPrintAsAnonymousBit, bool, 1, _) \
V(HasReportedBinaryCoverageBit, bool, 1, _) \
V(IsNamedExpressionBit, bool, 1, _) \
V(IsTopLevelBit, bool, 1, _)
V(IsTopLevelBit, bool, 1, _) \
V(IsIIFEBit, bool, 1, _)
DEFINE_BIT_FIELDS(FLAGS_BIT_FIELDS)
#undef FLAGS_BIT_FIELDS
......
......@@ -79,6 +79,7 @@ void ParseInfo::SetFunctionInfo(T function) {
set_requires_instance_members_initializer(
function->requires_instance_members_initializer());
set_toplevel(function->is_toplevel());
set_is_iife(function->is_iife());
set_wrapped_as_function(function->is_wrapped());
}
......
......@@ -114,6 +114,7 @@ class V8_EXPORT_PRIVATE ParseInfo {
set_allow_harmony_private_fields);
FLAG_ACCESSOR(kAllowHarmonyPrivateMethods, allow_harmony_private_methods,
set_allow_harmony_private_methods);
FLAG_ACCESSOR(kIsIIFE, is_iife, set_is_iife);
#undef FLAG_ACCESSOR
void set_parse_restriction(ParseRestriction restriction) {
......@@ -309,7 +310,8 @@ class V8_EXPORT_PRIVATE ParseInfo {
kAllowHarmonyImportMeta = 1 << 25,
kAllowHarmonyNumericSeparator = 1 << 26,
kAllowHarmonyPrivateFields = 1 << 27,
kAllowHarmonyPrivateMethods = 1 << 28
kAllowHarmonyPrivateMethods = 1 << 28,
kIsIIFE = 1 << 29
};
//------------- Inputs to parsing and scope analysis -----------------------
......
......@@ -852,6 +852,9 @@ FunctionLiteral* Parser::DoParseFunction(Isolate* isolate, ParseInfo* info,
if (has_error()) return nullptr;
result->set_requires_instance_members_initializer(
info->requires_instance_members_initializer());
if (info->is_iife()) {
result->mark_as_iife();
}
}
// Make sure the target stack is empty.
......
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