[runtime] Remove SharedFunctionInfo::is_function which is the inverse of SFI::is_toplevel

BUG=

Review-Url: https://codereview.chromium.org/2629143002
Cr-Commit-Position: refs/heads/master@{#42275}
This commit is contained in:
verwaest 2017-01-12 08:16:12 -08:00 committed by Commit bot
parent aff64e9dfa
commit 75a2fce3a2
7 changed files with 10 additions and 22 deletions

View File

@ -2629,8 +2629,6 @@ class FunctionLiteral final : public Expression {
return HasDuplicateParameters::decode(bit_field_);
}
bool is_function() const { return IsFunction::decode(bit_field_); }
// This is used as a heuristic on when to eagerly compile a function
// literal. We consider the following constructs as hints that the
// function will be called immediately:
@ -2695,7 +2693,7 @@ class FunctionLiteral final : public Expression {
int function_length, FunctionType function_type,
ParameterFlag has_duplicate_parameters,
EagerCompileHint eager_compile_hint, int position,
bool is_function, bool has_braces, int function_literal_id)
bool has_braces, int function_literal_id)
: Expression(position, kFunctionLiteral),
materialized_literal_count_(materialized_literal_count),
expected_property_count_(expected_property_count),
@ -2714,7 +2712,6 @@ class FunctionLiteral final : public Expression {
Pretenure::encode(false) |
HasDuplicateParameters::encode(has_duplicate_parameters ==
kHasDuplicateParameters) |
IsFunction::encode(is_function) |
ShouldNotBeUsedOnceHintField::encode(false) |
DontOptimizeReasonField::encode(kNoReason);
if (eager_compile_hint == kShouldEagerCompile) SetShouldEagerCompile();
@ -2724,9 +2721,8 @@ class FunctionLiteral final : public Expression {
: public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {};
class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {};
class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {};
class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {};
class ShouldNotBeUsedOnceHintField
: public BitField<bool, IsFunction::kNext, 1> {};
: public BitField<bool, HasDuplicateParameters::kNext, 1> {};
class DontOptimizeReasonField
: public BitField<BailoutReason, ShouldNotBeUsedOnceHintField::kNext, 8> {
};
@ -3479,7 +3475,7 @@ class AstNodeFactory final BASE_EMBEDDED {
zone_, name, ast_value_factory_, scope, body,
materialized_literal_count, expected_property_count, parameter_count,
function_length, function_type, has_duplicate_parameters,
eager_compile_hint, position, true, has_braces, function_literal_id);
eager_compile_hint, position, has_braces, function_literal_id);
}
// Creates a FunctionLiteral representing a top-level script, the
@ -3494,7 +3490,7 @@ class AstNodeFactory final BASE_EMBEDDED {
body, materialized_literal_count, expected_property_count,
parameter_count, parameter_count, FunctionLiteral::kAnonymousExpression,
FunctionLiteral::kNoDuplicateParameters,
FunctionLiteral::kShouldLazyCompile, 0, false, true,
FunctionLiteral::kShouldLazyCompile, 0, true,
FunctionLiteral::kIdTypeTopLevel);
}

View File

@ -240,7 +240,7 @@ bool CompilerDispatcher::Enqueue(Handle<SharedFunctionInfo> function) {
// We only handle functions (no eval / top-level code / wasm) that are
// attached to a script.
if (!function->script()->IsScript() || !function->is_function() ||
if (!function->script()->IsScript() || function->is_toplevel() ||
function->asm_function() || function->native()) {
return false;
}

View File

@ -225,7 +225,7 @@ void DebugEvaluate::ContextBuilder::MaterializeArgumentsObject(
Handle<JSObject> target, Handle<JSFunction> function) {
// Do not materialize the arguments object for eval or top-level code.
// Skip if "arguments" is already taken.
if (!function->shared()->is_function()) return;
if (function->shared()->is_toplevel()) return;
Maybe<bool> maybe = JSReceiver::HasOwnProperty(
target, isolate_->factory()->arguments_string());
DCHECK(maybe.IsJust());

View File

@ -6217,7 +6217,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
kNameShouldPrintAsAnonymous)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_anonymous_expression,
kIsAnonymousExpression)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_function, kIsFunction)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, must_use_ignition_turbo,
kMustUseIgnitionTurbo)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, dont_flush, kDontFlush)

View File

@ -13570,7 +13570,6 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
shared_info->set_language_mode(lit->language_mode());
shared_info->set_uses_arguments(lit->scope()->arguments() != NULL);
shared_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
shared_info->set_is_function(lit->is_function());
shared_info->set_kind(lit->kind());
if (!IsConstructable(lit->kind(), lit->language_mode())) {
shared_info->SetConstructStub(

View File

@ -7438,9 +7438,6 @@ class SharedFunctionInfo: public HeapObject {
// which does not change this flag).
DECL_BOOLEAN_ACCESSORS(is_anonymous_expression)
// Is this a function or top-level/eval code.
DECL_BOOLEAN_ACCESSORS(is_function)
// Indicates that code for this function must be compiled through the
// Ignition / TurboFan pipeline, and is unsupported by
// FullCodegen / Crankshaft.
@ -7746,10 +7743,11 @@ class SharedFunctionInfo: public HeapObject {
kIsAsmFunction,
kIsAnonymousExpression,
kNameShouldPrintAsAnonymous,
kIsFunction,
kMustUseIgnitionTurbo,
kDontFlush,
kIsDeclaration,
kUnused, // unused.
// byte 2
kFunctionKind,
// rest of byte 2 and first two bits of byte 3 are used by FunctionKind

View File

@ -351,12 +351,8 @@ Handle<String> RenderCallSite(Isolate* isolate, Handle<Object> object) {
MessageLocation location;
if (ComputeLocation(isolate, &location)) {
Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<ParseInfo> info;
if (location.function()->shared()->is_function()) {
info.reset(new ParseInfo(&zone, handle(location.function()->shared())));
} else {
info.reset(new ParseInfo(&zone, location.script()));
}
std::unique_ptr<ParseInfo> info(
new ParseInfo(&zone, handle(location.function()->shared())));
if (parsing::ParseAny(info.get())) {
CallPrinter printer(isolate,
location.function()->shared()->IsUserJavaScript());