Commit 688dcc3a authored by titzer's avatar titzer Committed by Commit bot

Move SetFunctionInfo() from compiler.cc to objects.cc. Rationale: not related to generating code.

R=verwaest@chromium.org
BUG=

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

Cr-Commit-Position: refs/heads/master@{#26583}
parent 81544f28
......@@ -609,47 +609,6 @@ static void MaybeDisableOptimization(Handle<SharedFunctionInfo> shared_info,
}
// Sets the function info on a function.
// The start_position points to the first '(' character after the function name
// in the full script source. When counting characters in the script source the
// the first character is number 0 (not 1).
static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
FunctionLiteral* lit,
bool is_toplevel,
Handle<Script> script) {
function_info->set_length(lit->parameter_count());
if (FLAG_experimental_classes && IsSubclassConstructor(lit->kind())) {
function_info->set_internal_formal_parameter_count(lit->parameter_count() +
1);
} else {
function_info->set_internal_formal_parameter_count(lit->parameter_count());
}
function_info->set_script(*script);
function_info->set_function_token_position(lit->function_token_position());
function_info->set_start_position(lit->start_position());
function_info->set_end_position(lit->end_position());
function_info->set_is_expression(lit->is_expression());
function_info->set_is_anonymous(lit->is_anonymous());
function_info->set_is_toplevel(is_toplevel);
function_info->set_inferred_name(*lit->inferred_name());
function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
function_info->set_allows_lazy_compilation_without_context(
lit->AllowsLazyCompilationWithoutContext());
function_info->set_language_mode(lit->language_mode());
function_info->set_uses_arguments(lit->scope()->arguments() != NULL);
function_info->set_has_duplicate_parameters(lit->has_duplicate_parameters());
function_info->set_ast_node_count(lit->ast_node_count());
function_info->set_is_function(lit->is_function());
MaybeDisableOptimization(function_info, lit->dont_optimize_reason());
function_info->set_dont_cache(lit->flags()->Contains(kDontCache));
function_info->set_kind(lit->kind());
function_info->set_uses_super_property(lit->uses_super_property());
function_info->set_uses_super_constructor_call(
lit->uses_super_constructor_call());
function_info->set_asm_function(lit->scope()->asm_function());
}
static void RecordFunctionCompilation(Logger::LogEventsAndTags tag,
CompilationInfo* info,
Handle<SharedFunctionInfo> shared) {
......@@ -1194,7 +1153,9 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
info->feedback_vector());
DCHECK_EQ(RelocInfo::kNoPosition, lit->function_token_position());
SetFunctionInfo(result, lit, true, script);
SharedFunctionInfo::InitFromFunctionLiteral(result, lit);
result->set_script(*script);
result->set_is_toplevel(true);
Handle<String> script_name = script->name()->IsString()
? Handle<String>(String::cast(script->name()))
......@@ -1468,7 +1429,11 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
Handle<SharedFunctionInfo> result = factory->NewSharedFunctionInfo(
literal->name(), literal->materialized_literal_count(), literal->kind(),
info.code(), scope_info, info.feedback_vector());
SetFunctionInfo(result, literal, false, script);
SharedFunctionInfo::InitFromFunctionLiteral(result, literal);
result->set_script(*script);
result->set_is_toplevel(false);
RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
result->set_allows_lazy_compilation(allow_lazy);
result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
......
......@@ -10378,6 +10378,42 @@ void SharedFunctionInfo::DisableOptimization(BailoutReason reason) {
}
void SharedFunctionInfo::InitFromFunctionLiteral(
Handle<SharedFunctionInfo> shared_info, FunctionLiteral* lit) {
shared_info->set_length(lit->parameter_count());
if (FLAG_experimental_classes && IsSubclassConstructor(lit->kind())) {
shared_info->set_internal_formal_parameter_count(lit->parameter_count() +
1);
} else {
shared_info->set_internal_formal_parameter_count(lit->parameter_count());
}
shared_info->set_function_token_position(lit->function_token_position());
shared_info->set_start_position(lit->start_position());
shared_info->set_end_position(lit->end_position());
shared_info->set_is_expression(lit->is_expression());
shared_info->set_is_anonymous(lit->is_anonymous());
shared_info->set_inferred_name(*lit->inferred_name());
shared_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
shared_info->set_allows_lazy_compilation_without_context(
lit->AllowsLazyCompilationWithoutContext());
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_ast_node_count(lit->ast_node_count());
shared_info->set_is_function(lit->is_function());
if (lit->dont_optimize_reason() != kNoReason) {
shared_info->DisableOptimization(lit->dont_optimize_reason());
}
shared_info->set_dont_cache(
lit->flags()->Contains(AstPropertiesFlag::kDontCache));
shared_info->set_kind(lit->kind());
shared_info->set_uses_super_property(lit->uses_super_property());
shared_info->set_uses_super_constructor_call(
lit->uses_super_constructor_call());
shared_info->set_asm_function(lit->scope()->asm_function());
}
bool SharedFunctionInfo::VerifyBailoutId(BailoutId id) {
DCHECK(!id.IsNone());
Code* unoptimized = code();
......
......@@ -857,6 +857,8 @@ class ObjectVisitor;
class StringStream;
class TypeFeedbackVector;
class WeakCell;
class FunctionLiteral;
// We cannot just say "class HeapType;" if it is created from a template... =8-?
template<class> class TypeImpl;
struct HeapTypeConfig;
......@@ -6739,6 +6741,10 @@ class SharedFunctionInfo: public HeapObject {
// Trims the optimized code map after entries have been removed.
void TrimOptimizedCodeMap(int shrink_by);
// Initialize a SharedFunctionInfo from a parsed function literal.
static void InitFromFunctionLiteral(Handle<SharedFunctionInfo> shared_info,
FunctionLiteral* lit);
// Add a new entry to the optimized code map.
static void AddToOptimizedCodeMap(Handle<SharedFunctionInfo> shared,
Handle<Context> native_context,
......
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