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

Side by Side Diff: src/interpreter/bytecode-generator.cc

Issue 2614053002: Improve error message for calling super() twice in a derived constructor (Closed)
Patch Set: Merged Created 3 years, 11 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 unified diff | Download patch
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/interpreter/bytecode-generator.h" 5 #include "src/interpreter/bytecode-generator.h"
6 6
7 #include "src/ast/compile-time-value.h" 7 #include "src/ast/compile-time-value.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/builtins/builtins-constructor.h" 9 #include "src/builtins/builtins-constructor.h"
10 #include "src/code-stubs.h" 10 #include "src/code-stubs.h"
(...skipping 1965 matching lines...) Expand 10 before | Expand all | Expand 10 after
1976 1976
1977 void BytecodeGenerator::BuildThrowIfHole(Handle<String> name) { 1977 void BytecodeGenerator::BuildThrowIfHole(Handle<String> name) {
1978 // TODO(interpreter): Can the parser reduce the number of checks 1978 // TODO(interpreter): Can the parser reduce the number of checks
1979 // performed? Or should there be a ThrowIfHole bytecode. 1979 // performed? Or should there be a ThrowIfHole bytecode.
1980 BytecodeLabel no_reference_error; 1980 BytecodeLabel no_reference_error;
1981 builder()->JumpIfNotHole(&no_reference_error); 1981 builder()->JumpIfNotHole(&no_reference_error);
1982 BuildThrowReferenceError(name); 1982 BuildThrowReferenceError(name);
1983 builder()->Bind(&no_reference_error); 1983 builder()->Bind(&no_reference_error);
1984 } 1984 }
1985 1985
1986 void BytecodeGenerator::BuildThrowIfNotHole(Handle<String> name) {
1987 // TODO(interpreter): Can the parser reduce the number of checks
1988 // performed? Or should there be a ThrowIfNotHole bytecode.
1989 BytecodeLabel no_reference_error, reference_error;
1990 builder()
1991 ->JumpIfNotHole(&reference_error)
1992 .Jump(&no_reference_error)
1993 .Bind(&reference_error);
1994 BuildThrowReferenceError(name);
1995 builder()->Bind(&no_reference_error);
1996 }
1997
1998 void BytecodeGenerator::BuildHoleCheckForVariableAssignment(Variable* variable, 1986 void BytecodeGenerator::BuildHoleCheckForVariableAssignment(Variable* variable,
1999 Token::Value op) { 1987 Token::Value op) {
2000 if (variable->is_this() && variable->mode() == CONST && op == Token::INIT) { 1988 if (variable->is_this() && variable->mode() == CONST && op == Token::INIT) {
2001 // Perform an initialization check for 'this'. 'this' variable is the 1989 // Perform an initialization check for 'this'. 'this' variable is the
2002 // only variable able to trigger bind operations outside the TDZ 1990 // only variable able to trigger bind operations outside the TDZ
2003 // via 'super' calls. 1991 // via 'super' calls.
2004 BuildThrowIfNotHole(variable->name()); 1992 BytecodeLabel no_reference_error, reference_error;
1993 builder()
1994 ->JumpIfNotHole(&reference_error)
1995 .Jump(&no_reference_error)
1996 .Bind(&reference_error)
1997 .CallRuntime(Runtime::kThrowSuperAlreadyCalledError)
1998 .Bind(&no_reference_error);
2005 } else { 1999 } else {
2006 // Perform an initialization check for let/const declared variables. 2000 // Perform an initialization check for let/const declared variables.
2007 // E.g. let x = (x = 20); is not allowed. 2001 // E.g. let x = (x = 20); is not allowed.
2008 DCHECK(IsLexicalVariableMode(variable->mode())); 2002 DCHECK(IsLexicalVariableMode(variable->mode()));
2009 BuildThrowIfHole(variable->name()); 2003 BuildThrowIfHole(variable->name());
2010 } 2004 }
2011 } 2005 }
2012 2006
2013 void BytecodeGenerator::BuildVariableAssignment(Variable* variable, 2007 void BytecodeGenerator::BuildVariableAssignment(Variable* variable,
2014 Token::Value op, 2008 Token::Value op,
(...skipping 1316 matching lines...) Expand 10 before | Expand all | Expand 10 after
3331 } 3325 }
3332 3326
3333 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() { 3327 Runtime::FunctionId BytecodeGenerator::StoreKeyedToSuperRuntimeId() {
3334 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict 3328 return is_strict(language_mode()) ? Runtime::kStoreKeyedToSuper_Strict
3335 : Runtime::kStoreKeyedToSuper_Sloppy; 3329 : Runtime::kStoreKeyedToSuper_Sloppy;
3336 } 3330 }
3337 3331
3338 } // namespace interpreter 3332 } // namespace interpreter
3339 } // namespace internal 3333 } // namespace internal
3340 } // namespace v8 3334 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/bytecode-generator.h ('k') | src/messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698