Commit 1abf3ed0 authored by rossberg@chromium.org's avatar rossberg@chromium.org

Introduce collective --harmony flag.

Shorten --harmony-block-scoping to --harmony-scoping.

R=keuchel@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/8226017

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 819323f2
......@@ -1413,7 +1413,7 @@ void ObjectTemplate::SetInternalFieldCount(int value) {
ScriptData* ScriptData::PreCompile(const char* input, int length) {
i::Utf8ToUC16CharacterStream stream(
reinterpret_cast<const unsigned char*>(input), length);
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping);
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
}
......@@ -1422,10 +1422,10 @@ ScriptData* ScriptData::PreCompile(v8::Handle<String> source) {
if (str->IsExternalTwoByteString()) {
i::ExternalTwoByteStringUC16CharacterStream stream(
i::Handle<i::ExternalTwoByteString>::cast(str), 0, str->length());
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping);
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
} else {
i::GenericStringUC16CharacterStream stream(str, 0, str->length());
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_block_scoping);
return i::ParserApi::PreParse(&stream, NULL, i::FLAG_harmony_scoping);
}
}
......
......@@ -2139,10 +2139,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
__ push(r1);
// Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag();
if (FLAG_harmony_block_scoping) {
strict_mode = kStrictMode;
}
StrictModeFlag strict_mode =
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ mov(r1, Operand(Smi::FromInt(strict_mode)));
__ push(r1);
......
......@@ -480,8 +480,7 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
// that would be compiled lazily anyway, so we skip the preparse step
// in that case too.
ScriptDataImpl* pre_data = input_pre_data;
bool harmony_block_scoping = natives != NATIVES_CODE &&
FLAG_harmony_block_scoping;
bool harmony_scoping = natives != NATIVES_CODE && FLAG_harmony_scoping;
if (pre_data == NULL
&& source_length >= FLAG_min_preparse_length) {
if (source->IsExternalTwoByteString()) {
......@@ -489,12 +488,12 @@ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
Handle<ExternalTwoByteString>::cast(source), 0, source->length());
pre_data = ParserApi::PartialPreParse(&stream,
extension,
harmony_block_scoping);
harmony_scoping);
} else {
GenericStringUC16CharacterStream stream(source, 0, source->length());
pre_data = ParserApi::PartialPreParse(&stream,
extension,
harmony_block_scoping);
harmony_scoping);
}
}
......
......@@ -98,9 +98,10 @@ private:
// Flags for experimental language features.
DEFINE_bool(harmony_typeof, false, "enable harmony semantics for typeof")
DEFINE_bool(harmony_scoping, false, "enable harmony block scoping")
DEFINE_bool(harmony_proxies, false, "enable harmony proxies")
DEFINE_bool(harmony_weakmaps, false, "enable harmony weak maps")
DEFINE_bool(harmony_block_scoping, false, "enable harmony block scoping")
DEFINE_bool(harmony, false, "enable all harmony features")
// Flags for experimental implementation features.
DEFINE_bool(unbox_double_arrays, true, "automatically unbox arrays of doubles")
......
......@@ -2143,10 +2143,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
// Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag();
if (FLAG_harmony_block_scoping) {
strict_mode = kStrictMode;
}
StrictModeFlag strict_mode =
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ push(Immediate(Smi::FromInt(strict_mode)));
__ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
......
......@@ -2136,10 +2136,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
__ push(a1);
// Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag();
if (FLAG_harmony_block_scoping) {
strict_mode = kStrictMode;
}
StrictModeFlag strict_mode =
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ li(a1, Operand(Smi::FromInt(strict_mode)));
__ push(a1);
......
......@@ -587,7 +587,7 @@ Parser::Parser(Handle<Script> script,
fni_(NULL),
stack_overflow_(false),
parenthesized_function_(false),
harmony_block_scoping_(false) {
harmony_scoping_(false) {
AstNode::ResetIds();
}
......@@ -650,7 +650,7 @@ FunctionLiteral* Parser::DoParseProgram(Handle<String> source,
CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok);
}
if (ok && harmony_block_scoping_) {
if (ok && harmony_scoping_) {
CheckConflictingVarDeclarations(scope, &ok);
}
......@@ -817,9 +817,9 @@ void Parser::ReportMessageAt(Scanner::Location source_location,
isolate()->Throw(*result, &location);
}
void Parser::SetHarmonyBlockScoping(bool block_scoping) {
scanner().SetHarmonyBlockScoping(block_scoping);
harmony_block_scoping_ = block_scoping;
void Parser::SetHarmonyScoping(bool block_scoping) {
scanner().SetHarmonyScoping(block_scoping);
harmony_scoping_ = block_scoping;
}
// Base class containing common code for the different finder classes used by
......@@ -1390,7 +1390,7 @@ VariableProxy* Parser::Declare(Handle<String> name,
ASSERT(var->mode() == VAR ||
var->mode() == CONST ||
var->mode() == LET);
if (harmony_block_scoping_) {
if (harmony_scoping_) {
// In harmony mode we treat re-declarations as early errors. See
// ES5 16 for a definition of early errors.
SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS);
......@@ -1542,14 +1542,14 @@ Statement* Parser::ParseFunctionDeclaration(bool* ok) {
// Even if we're not at the top-level of the global or a function
// scope, we treat is as such and introduce the function with it's
// initial value upon entering the corresponding scope.
VariableMode mode = harmony_block_scoping_ ? LET : VAR;
VariableMode mode = harmony_scoping_ ? LET : VAR;
Declare(name, mode, fun, true, CHECK_OK);
return EmptyStatement();
}
Block* Parser::ParseBlock(ZoneStringList* labels, bool* ok) {
if (harmony_block_scoping_) return ParseScopedBlock(labels, ok);
if (harmony_scoping_) return ParseScopedBlock(labels, ok);
// Block ::
// '{' Statement* '}'
......@@ -2249,7 +2249,7 @@ TryStatement* Parser::ParseTryStatement(bool* ok) {
if (top_scope_->is_strict_mode()) {
catch_scope->EnableStrictMode();
}
VariableMode mode = harmony_block_scoping_ ? LET : VAR;
VariableMode mode = harmony_scoping_ ? LET : VAR;
catch_variable = catch_scope->DeclareLocal(name, mode);
Scope* saved_scope = top_scope_;
......@@ -3714,8 +3714,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
// Function declarations are function scoped in normal mode, so they are
// hoisted. In harmony block scoping mode they are block scoped, so they
// are not hoisted.
Scope* scope = (type == FunctionLiteral::DECLARATION &&
!harmony_block_scoping_)
Scope* scope = (type == FunctionLiteral::DECLARATION && !harmony_scoping_)
? NewScope(top_scope_->DeclarationScope(), Scope::FUNCTION_SCOPE, false)
: NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with());
ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8);
......@@ -3757,8 +3756,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
reserved_loc = scanner().location();
}
top_scope_->DeclareParameter(param_name,
harmony_block_scoping_ ? LET : VAR);
top_scope_->DeclareParameter(param_name, harmony_scoping_ ? LET : VAR);
num_parameters++;
if (num_parameters > kMaxNumFunctionParameters) {
ReportMessageAt(scanner().location(), "too_many_parameters",
......@@ -3885,7 +3883,7 @@ FunctionLiteral* Parser::ParseFunctionLiteral(Handle<String> function_name,
}
}
if (harmony_block_scoping_) {
if (harmony_scoping_) {
CheckConflictingVarDeclarations(scope, CHECK_OK);
}
......@@ -5123,10 +5121,10 @@ int ScriptDataImpl::ReadNumber(byte** source) {
static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
bool allow_lazy,
ParserRecorder* recorder,
bool harmony_block_scoping) {
bool harmony_scoping) {
Isolate* isolate = Isolate::Current();
JavaScriptScanner scanner(isolate->unicode_cache());
scanner.SetHarmonyBlockScoping(harmony_block_scoping);
scanner.SetHarmonyScoping(harmony_scoping);
scanner.Initialize(source);
intptr_t stack_limit = isolate->stack_guard()->real_climit();
if (!preparser::PreParser::PreParseProgram(&scanner,
......@@ -5148,7 +5146,7 @@ static ScriptDataImpl* DoPreParse(UC16CharacterStream* source,
// even if the preparser data is only used once.
ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source,
v8::Extension* extension,
bool harmony_block_scoping) {
bool harmony_scoping) {
bool allow_lazy = FLAG_lazy && (extension == NULL);
if (!allow_lazy) {
// Partial preparsing is only about lazily compiled functions.
......@@ -5156,17 +5154,17 @@ ScriptDataImpl* ParserApi::PartialPreParse(UC16CharacterStream* source,
return NULL;
}
PartialParserRecorder recorder;
return DoPreParse(source, allow_lazy, &recorder, harmony_block_scoping);
return DoPreParse(source, allow_lazy, &recorder, harmony_scoping);
}
ScriptDataImpl* ParserApi::PreParse(UC16CharacterStream* source,
v8::Extension* extension,
bool harmony_block_scoping) {
bool harmony_scoping) {
Handle<Script> no_script;
bool allow_lazy = FLAG_lazy && (extension == NULL);
CompleteParserRecorder recorder;
return DoPreParse(source, allow_lazy, &recorder, harmony_block_scoping);
return DoPreParse(source, allow_lazy, &recorder, harmony_scoping);
}
......@@ -5196,11 +5194,10 @@ bool ParserApi::Parse(CompilationInfo* info) {
ASSERT(info->function() == NULL);
FunctionLiteral* result = NULL;
Handle<Script> script = info->script();
bool harmony_block_scoping = !info->is_native() &&
FLAG_harmony_block_scoping;
bool harmony_scoping = !info->is_native() && FLAG_harmony_scoping;
if (info->is_lazy()) {
Parser parser(script, true, NULL, NULL);
parser.SetHarmonyBlockScoping(harmony_block_scoping);
parser.SetHarmonyScoping(harmony_scoping);
result = parser.ParseLazy(info);
} else {
// Whether we allow %identifier(..) syntax.
......@@ -5211,7 +5208,7 @@ bool ParserApi::Parse(CompilationInfo* info) {
allow_natives_syntax,
info->extension(),
pre_data);
parser.SetHarmonyBlockScoping(harmony_block_scoping);
parser.SetHarmonyScoping(harmony_scoping);
if (pre_data != NULL && pre_data->has_error()) {
Scanner::Location loc = pre_data->MessageLocation();
const char* message = pre_data->BuildMessage();
......
......@@ -164,13 +164,13 @@ class ParserApi {
// Generic preparser generating full preparse data.
static ScriptDataImpl* PreParse(UC16CharacterStream* source,
v8::Extension* extension,
bool harmony_block_scoping);
bool harmony_scoping);
// Preparser that only does preprocessing that makes sense if only used
// immediately after.
static ScriptDataImpl* PartialPreParse(UC16CharacterStream* source,
v8::Extension* extension,
bool harmony_block_scoping);
bool harmony_scoping);
};
// ----------------------------------------------------------------------------
......@@ -436,7 +436,7 @@ class Parser {
void ReportMessageAt(Scanner::Location loc,
const char* message,
Vector<Handle<String> > args);
void SetHarmonyBlockScoping(bool block_scoping);
void SetHarmonyScoping(bool block_scoping);
private:
// Limit on number of function parameters is chosen arbitrarily.
......@@ -731,7 +731,7 @@ class Parser {
// Heuristically that means that the function will be called immediately,
// so never lazily compile it.
bool parenthesized_function_;
bool harmony_block_scoping_;
bool harmony_scoping_;
friend class LexicalScope;
};
......
......@@ -293,7 +293,7 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
//
Expect(i::Token::LBRACE, CHECK_OK);
while (peek() != i::Token::RBRACE) {
if (harmony_block_scoping_) {
if (harmony_scoping_) {
ParseSourceElement(CHECK_OK);
} else {
ParseStatement(CHECK_OK);
......
......@@ -447,7 +447,7 @@ class PreParser {
stack_overflow_(false),
allow_lazy_(true),
parenthesized_function_(false),
harmony_block_scoping_(scanner->HarmonyBlockScoping()) { }
harmony_scoping_(scanner->HarmonyScoping()) { }
// Preparse the program. Only called in PreParseProgram after creating
// the instance.
......@@ -608,7 +608,7 @@ class PreParser {
bool stack_overflow_;
bool allow_lazy_;
bool parenthesized_function_;
bool harmony_block_scoping_;
bool harmony_scoping_;
};
} } // v8::preparser
......
......@@ -95,7 +95,7 @@ uc32 Scanner::ScanHexNumber(int expected_length) {
JavaScriptScanner::JavaScriptScanner(UnicodeCache* scanner_contants)
: Scanner(scanner_contants),
octal_pos_(Location::invalid()),
harmony_block_scoping_(false) { }
harmony_scoping_(false) { }
void JavaScriptScanner::Initialize(UC16CharacterStream* source) {
......@@ -872,7 +872,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() {
KEYWORD("instanceof", Token::INSTANCEOF) \
KEYWORD("interface", Token::FUTURE_STRICT_RESERVED_WORD) \
KEYWORD_GROUP('l') \
KEYWORD("let", harmony_block_scoping \
KEYWORD("let", harmony_scoping \
? Token::LET : Token::FUTURE_STRICT_RESERVED_WORD) \
KEYWORD_GROUP('n') \
KEYWORD("new", Token::NEW) \
......@@ -906,7 +906,7 @@ uc32 JavaScriptScanner::ScanIdentifierUnicodeEscape() {
static Token::Value KeywordOrIdentifierToken(const char* input,
int input_length,
bool harmony_block_scoping) {
bool harmony_scoping) {
ASSERT(input_length >= 1);
const int kMinLength = 2;
const int kMaxLength = 10;
......@@ -982,7 +982,7 @@ Token::Value JavaScriptScanner::ScanIdentifierOrKeyword() {
Vector<const char> chars = next_.literal_chars->ascii_literal();
return KeywordOrIdentifierToken(chars.start(),
chars.length(),
harmony_block_scoping_);
harmony_scoping_);
}
return Token::IDENTIFIER;
......
......@@ -509,11 +509,11 @@ class JavaScriptScanner : public Scanner {
// tokens, which is what it is used for.
void SeekForward(int pos);
bool HarmonyBlockScoping() const {
return harmony_block_scoping_;
bool HarmonyScoping() const {
return harmony_scoping_;
}
void SetHarmonyBlockScoping(bool block_scoping) {
harmony_block_scoping_ = block_scoping;
void SetHarmonyScoping(bool block_scoping) {
harmony_scoping_ = block_scoping;
}
......@@ -556,7 +556,7 @@ class JavaScriptScanner : public Scanner {
bool has_multiline_comment_before_next_;
// Whether we scan 'let' as a keyword for harmony block scoped
// let bindings.
bool harmony_block_scoping_;
bool harmony_scoping_;
};
} } // namespace v8::internal
......
......@@ -57,6 +57,15 @@ static EntropySource entropy_source;
bool V8::Initialize(Deserializer* des) {
// Setting --harmony implies all other harmony flags.
// TODO(rossberg): Is there a better place to put this?
if (FLAG_harmony) {
FLAG_harmony_typeof = true;
FLAG_harmony_scoping = true;
FLAG_harmony_proxies = true;
FLAG_harmony_weakmaps = true;
}
InitializeOncePerProcess();
// The current thread may not yet had entered an isolate to run.
......
......@@ -2029,10 +2029,8 @@ void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
// Push the strict mode flag. In harmony mode every eval call
// is a strict mode eval call.
StrictModeFlag strict_mode = strict_mode_flag();
if (FLAG_harmony_block_scoping) {
strict_mode = kStrictMode;
}
StrictModeFlag strict_mode =
FLAG_harmony_scoping ? kStrictMode : strict_mode_flag();
__ Push(Smi::FromInt(strict_mode));
__ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
......
......@@ -65,7 +65,7 @@ TEST(ScanKeywords) {
i::Utf8ToUC16CharacterStream stream(keyword, length);
i::JavaScriptScanner scanner(&unicode_cache);
// The scanner should parse 'let' as Token::LET for this test.
scanner.SetHarmonyBlockScoping(true);
scanner.SetHarmonyScoping(true);
scanner.Initialize(&stream);
CHECK_EQ(key_token.token, scanner.Next());
CHECK_EQ(i::Token::EOS, scanner.Next());
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping
// Flags: --expose-debug-as debug --harmony-scoping
// The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping
// Flags: --harmony-scoping
// Test for conflicting variable bindings.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping
// Flags: --harmony-scoping
// We want to test the context chain shape. In each of the tests cases
// below, the outer with is to force a runtime lookup of the identifier 'x'
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping --allow-natives-syntax
// Flags: --harmony-scoping --allow-natives-syntax
// Test that temporal dead zone semantics for function and block scoped
// ket bindings are handled by the optimizing compiler.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping
// Flags: --harmony-scoping
// Test let declarations in various settings.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --harmony-block-scoping
// Flags: --harmony-scoping
// Test temporal dead zone semantics of let bound variables in
// function and block scopes.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --allow-natives-syntax --harmony-block-scoping
// Flags: --allow-natives-syntax --harmony-scoping
// Test functionality of block scopes.
// Hoisting of var declarations.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping
// Flags: --expose-debug-as debug --harmony-scoping
// The functions used for testing backtraces. They are at the top to make the
// testing of source line/column easier.
......
......@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --expose-debug-as debug --harmony-block-scoping
// Flags: --expose-debug-as debug --harmony-scoping
// Test debug evaluation for functions without local context, but with
// nested catch contexts.
......
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