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

Unified Diff: src/parsing/parser.cc

Issue 2788033002: [es2015] Simplify contract between parser and stub for derived constructors. (Closed)
Patch Set: Manual register allocation... Created 3 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/builtins/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/parser.cc
diff --git a/src/parsing/parser.cc b/src/parsing/parser.cc
index a461c9d6f4fd2a009bbc32bac1763d9977e9a600..a644ef32e30f4ba517e33145ebb8f8325113a100 100644
--- a/src/parsing/parser.cc
+++ b/src/parsing/parser.cc
@@ -1593,42 +1593,29 @@ Block* Parser::IgnoreCompletion(Statement* statement) {
Expression* Parser::RewriteReturn(Expression* return_value, int pos) {
if (IsDerivedConstructor(function_state_->kind())) {
- // For subclass constructors we need to return this in case of undefined
- // return a Smi (transformed into an exception in the ConstructStub)
- // for a non object.
+ // For subclass constructors we need to return this in case of undefined;
+ // other primitive values trigger an exception in the ConstructStub.
//
// return expr;
//
// Is rewritten as:
//
- // return (temp = expr) === undefined ? this :
- // %_IsJSReceiver(temp) ? temp : 1;
+ // return (temp = expr) === undefined ? this : temp;
// temp = expr
Variable* temp = NewTemporary(ast_value_factory()->empty_string());
Assignment* assign = factory()->NewAssignment(
Token::ASSIGN, factory()->NewVariableProxy(temp), return_value, pos);
- // %_IsJSReceiver(temp)
- ZoneList<Expression*>* is_spec_object_args =
- new (zone()) ZoneList<Expression*>(1, zone());
- is_spec_object_args->Add(factory()->NewVariableProxy(temp), zone());
- Expression* is_spec_object_call = factory()->NewCallRuntime(
- Runtime::kInlineIsJSReceiver, is_spec_object_args, pos);
-
- // %_IsJSReceiver(temp) ? temp : 1;
- Expression* is_object_conditional = factory()->NewConditional(
- is_spec_object_call, factory()->NewVariableProxy(temp),
- factory()->NewSmiLiteral(1, pos), pos);
-
// temp === undefined
Expression* is_undefined = factory()->NewCompareOperation(
Token::EQ_STRICT, assign,
factory()->NewUndefinedLiteral(kNoSourcePosition), pos);
- // is_undefined ? this : is_object_conditional
- return_value = factory()->NewConditional(is_undefined, ThisExpression(pos),
- is_object_conditional, pos);
+ // is_undefined ? this : temp
+ return_value =
+ factory()->NewConditional(is_undefined, ThisExpression(pos),
+ factory()->NewVariableProxy(temp), pos);
}
return return_value;
}
« no previous file with comments | « src/builtins/x64/builtins-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698