Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Unified Diff: src/compiler.cc

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler.h ('k') | src/contexts.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 743d3336881a760894a6fabfe0a0855d86508b93..69b794d5c6322626fa01ba80da7d533b7fecc577 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -56,7 +56,7 @@ namespace internal {
CompilationInfo::CompilationInfo(Handle<Script> script,
Zone* zone)
- : flags_(LanguageModeField::encode(CLASSIC_MODE)),
+ : flags_(StrictModeField::encode(SLOPPY)),
script_(script),
osr_ast_id_(BailoutId::None()),
parameter_count_(0),
@@ -68,7 +68,7 @@ CompilationInfo::CompilationInfo(Handle<Script> script,
CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
Zone* zone)
- : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
+ : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)),
shared_info_(shared_info),
script_(Handle<Script>(Script::cast(shared_info->script()))),
osr_ast_id_(BailoutId::None()),
@@ -81,7 +81,7 @@ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info,
CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
Zone* zone)
- : flags_(LanguageModeField::encode(CLASSIC_MODE) | IsLazy::encode(true)),
+ : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)),
closure_(closure),
shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
script_(Handle<Script>(Script::cast(shared_info_->script()))),
@@ -97,8 +97,7 @@ CompilationInfo::CompilationInfo(Handle<JSFunction> closure,
CompilationInfo::CompilationInfo(HydrogenCodeStub* stub,
Isolate* isolate,
Zone* zone)
- : flags_(LanguageModeField::encode(CLASSIC_MODE) |
- IsLazy::encode(true)),
+ : flags_(StrictModeField::encode(SLOPPY) | IsLazy::encode(true)),
osr_ast_id_(BailoutId::None()),
parameter_count_(0),
this_has_uses_(true),
@@ -137,8 +136,8 @@ void CompilationInfo::Initialize(Isolate* isolate,
MarkAsNative();
}
if (!shared_info_.is_null()) {
- ASSERT(language_mode() == CLASSIC_MODE);
- SetLanguageMode(shared_info_->language_mode());
+ ASSERT(strict_mode() == SLOPPY);
+ SetStrictMode(shared_info_->strict_mode());
}
set_bailout_reason(kUnknown);
}
@@ -228,7 +227,7 @@ void CompilationInfo::DisableOptimization() {
FLAG_optimize_closures &&
closure_.is_null() &&
!scope_->HasTrivialOuterContext() &&
- !scope_->outer_scope_calls_non_strict_eval() &&
+ !scope_->outer_scope_calls_sloppy_eval() &&
!scope_->inside_with();
SetMode(is_optimizable_closure ? BASE : NONOPT);
}
@@ -250,6 +249,17 @@ void CompilationInfo::PrepareForCompilation(Scope* scope) {
ASSERT(scope_ == NULL);
scope_ = scope;
function()->ProcessFeedbackSlots(isolate_);
+ int length = function()->slot_count();
+ // Allocate the feedback vector too.
+ feedback_vector_ = isolate()->factory()->NewFixedArray(length, TENURED);
+ // Ensure we can skip the write barrier
+ ASSERT_EQ(isolate()->heap()->uninitialized_symbol(),
+ *TypeFeedbackInfo::UninitializedSentinel(isolate()));
+ for (int i = 0; i < length; i++) {
+ feedback_vector_->set(i,
+ *TypeFeedbackInfo::UninitializedSentinel(isolate()),
+ SKIP_WRITE_BARRIER);
+ }
}
@@ -571,6 +581,8 @@ static void UpdateSharedFunctionInfo(CompilationInfo* info) {
shared->ReplaceCode(*code);
if (shared->optimization_disabled()) code->set_optimizable(false);
+ shared->set_feedback_vector(*info->feedback_vector());
+
// Set the expected number of properties for instances.
FunctionLiteral* lit = info->function();
int expected = lit->expected_property_count();
@@ -581,7 +593,7 @@ static void UpdateSharedFunctionInfo(CompilationInfo* info) {
shared->set_dont_optimize_reason(lit->dont_optimize_reason());
shared->set_dont_inline(lit->flags()->Contains(kDontInline));
shared->set_ast_node_count(lit->ast_node_count());
- shared->set_language_mode(lit->language_mode());
+ shared->set_strict_mode(lit->strict_mode());
}
@@ -606,7 +618,7 @@ static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
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_strict_mode(lit->strict_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());
@@ -637,8 +649,7 @@ static Handle<Code> GetUnoptimizedCodeCommon(CompilationInfo* info) {
VMState<COMPILER> state(info->isolate());
PostponeInterruptsScope postpone(info->isolate());
if (!Parser::Parse(info)) return Handle<Code>::null();
- LanguageMode language_mode = info->function()->language_mode();
- info->SetLanguageMode(language_mode);
+ info->SetStrictMode(info->function()->strict_mode());
if (!CompileUnoptimizedCode(info)) return Handle<Code>::null();
Compiler::RecordFunctionCompilation(
@@ -746,8 +757,7 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
info.MarkAsGlobal();
if (!Parser::Parse(&info)) return;
- LanguageMode language_mode = info.function()->language_mode();
- info.SetLanguageMode(language_mode);
+ info.SetStrictMode(info.function()->strict_mode());
LiveEditFunctionTracker tracker(info.isolate(), info.function());
if (!CompileUnoptimizedCode(&info)) return;
@@ -826,7 +836,8 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
lit->materialized_literal_count(),
lit->is_generator(),
info->code(),
- ScopeInfo::Create(info->scope(), info->zone()));
+ ScopeInfo::Create(info->scope(), info->zone()),
+ info->feedback_vector());
ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
SetFunctionInfo(result, lit, true, script);
@@ -863,7 +874,7 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source,
Handle<Context> context,
- LanguageMode language_mode,
+ StrictMode strict_mode,
ParseRestriction restriction,
int scope_position) {
Isolate* isolate = source->GetIsolate();
@@ -873,14 +884,14 @@ Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source,
CompilationCache* compilation_cache = isolate->compilation_cache();
Handle<SharedFunctionInfo> shared_info = compilation_cache->LookupEval(
- source, context, language_mode, scope_position);
+ source, context, strict_mode, scope_position);
if (shared_info.is_null()) {
Handle<Script> script = isolate->factory()->NewScript(source);
CompilationInfoWithZone info(script);
info.MarkAsEval();
if (context->IsNativeContext()) info.MarkAsGlobal();
- info.SetLanguageMode(language_mode);
+ info.SetStrictMode(strict_mode);
info.SetParseRestriction(restriction);
info.SetContext(context);
@@ -897,14 +908,8 @@ Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source,
// to handle eval-code in the optimizing compiler.
shared_info->DisableOptimization(kEval);
- // If caller is strict mode, the result must be in strict mode or
- // extended mode as well, but not the other way around. Consider:
- // eval("'use strict'; ...");
- ASSERT(language_mode != STRICT_MODE || !shared_info->is_classic_mode());
- // If caller is in extended mode, the result must also be in
- // extended mode.
- ASSERT(language_mode != EXTENDED_MODE ||
- shared_info->is_extended_mode());
+ // If caller is strict mode, the result must be in strict mode as well.
+ ASSERT(strict_mode == SLOPPY || shared_info->strict_mode() == STRICT);
if (!shared_info->dont_cache()) {
compilation_cache->PutEval(
source, context, shared_info, scope_position);
@@ -927,7 +932,6 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source,
Handle<Context> context,
v8::Extension* extension,
ScriptDataImpl* pre_data,
- Handle<Object> script_data,
NativesFlag natives) {
Isolate* isolate = source->GetIsolate();
int source_length = source->length();
@@ -969,18 +973,13 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source,
}
script->set_is_shared_cross_origin(is_shared_cross_origin);
- script->set_data(script_data.is_null() ? isolate->heap()->undefined_value()
- : *script_data);
-
// Compile the function and add it to the cache.
CompilationInfoWithZone info(script);
info.MarkAsGlobal();
info.SetExtension(extension);
info.SetPreParseData(pre_data);
info.SetContext(context);
- if (FLAG_use_strict) {
- info.SetLanguageMode(FLAG_harmony_scoping ? EXTENDED_MODE : STRICT_MODE);
- }
+ if (FLAG_use_strict) info.SetStrictMode(STRICT);
result = CompileToplevel(&info);
if (extension == NULL && !result.is_null() && !result->dont_cache()) {
compilation_cache->PutScript(source, context, result);
@@ -1000,7 +999,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
CompilationInfoWithZone info(script);
info.SetFunction(literal);
info.PrepareForCompilation(literal->scope());
- info.SetLanguageMode(literal->scope()->language_mode());
+ info.SetStrictMode(literal->scope()->strict_mode());
Isolate* isolate = info.isolate();
Factory* factory = isolate->factory();
@@ -1037,7 +1036,8 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
literal->materialized_literal_count(),
literal->is_generator(),
info.code(),
- scope_info);
+ scope_info,
+ info.feedback_vector());
SetFunctionInfo(result, literal, false, script);
RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
result->set_allows_lazy_compilation(allow_lazy);
@@ -1095,8 +1095,7 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
static bool CompileOptimizedPrologue(CompilationInfo* info) {
if (!Parser::Parse(info)) return false;
- LanguageMode language_mode = info->function()->language_mode();
- info->SetLanguageMode(language_mode);
+ info->SetStrictMode(info->function()->strict_mode());
if (!Rewriter::Rewrite(info)) return false;
if (!Scope::Analyze(info)) return false;
« no previous file with comments | « src/compiler.h ('k') | src/contexts.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698