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

Side by Side Diff: src/parser.cc

Issue 919643008: Remove --experimental-classes flag and related dead code. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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/objects.cc ('k') | src/ppc/full-codegen-ppc.cc » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
265 265
266 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, 266 FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
267 int pos, int end_pos) { 267 int pos, int end_pos) {
268 int materialized_literal_count = -1; 268 int materialized_literal_count = -1;
269 int expected_property_count = -1; 269 int expected_property_count = -1;
270 int handler_count = 0; 270 int handler_count = 0;
271 int parameter_count = 0; 271 int parameter_count = 0;
272 const AstRawString* name = ast_value_factory()->empty_string(); 272 const AstRawString* name = ast_value_factory()->empty_string();
273 273
274 274
275 FunctionKind kind = call_super && !FLAG_experimental_classes 275 FunctionKind kind = call_super ? FunctionKind::kDefaultSubclassConstructor
276 ? FunctionKind::kDefaultBaseConstructor 276 : FunctionKind::kDefaultBaseConstructor;
277 : FunctionKind::kDefaultSubclassConstructor;
278 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind); 277 Scope* function_scope = NewScope(scope, FUNCTION_SCOPE, kind);
279 function_scope->SetLanguageMode( 278 function_scope->SetLanguageMode(
280 static_cast<LanguageMode>(scope->language_mode() | STRICT_BIT)); 279 static_cast<LanguageMode>(scope->language_mode() | STRICT_BIT));
281 // Set start and end position to the same value 280 // Set start and end position to the same value
282 function_scope->set_start_position(pos); 281 function_scope->set_start_position(pos);
283 function_scope->set_end_position(pos); 282 function_scope->set_end_position(pos);
284 ZoneList<Statement*>* body = NULL; 283 ZoneList<Statement*>* body = NULL;
285 284
286 { 285 {
287 AstNodeFactory function_factory(ast_value_factory()); 286 AstNodeFactory function_factory(ast_value_factory());
288 FunctionState function_state(&function_state_, &scope_, function_scope, 287 FunctionState function_state(&function_state_, &scope_, function_scope,
289 kind, &function_factory); 288 kind, &function_factory);
290 289
291 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); 290 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
292 AddAssertIsConstruct(body, pos); 291 AddAssertIsConstruct(body, pos);
293 if (call_super) { 292 if (call_super) {
294 ZoneList<Expression*>* args = 293 ZoneList<Expression*>* args =
295 new (zone()) ZoneList<Expression*>(0, zone()); 294 new (zone()) ZoneList<Expression*>(0, zone());
296 if (FLAG_experimental_classes) { 295 CallRuntime* call = factory()->NewCallRuntime(
297 CallRuntime* call = factory()->NewCallRuntime( 296 ast_value_factory()->empty_string(),
298 ast_value_factory()->empty_string(), 297 Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper),
299 Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper), 298 args, pos);
300 args, pos); 299 body->Add(factory()->NewReturnStatement(call, pos), zone());
301 body->Add(factory()->NewReturnStatement(call, pos), zone());
302 } else {
303 CallRuntime* call = factory()->NewCallRuntime(
304 ast_value_factory()->empty_string(),
305 Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args,
306 pos);
307 body->Add(factory()->NewExpressionStatement(call, pos), zone());
308 }
309 function_scope->RecordSuperConstructorCallUsage(); 300 function_scope->RecordSuperConstructorCallUsage();
310 } 301 }
311 302
312 materialized_literal_count = function_state.materialized_literal_count(); 303 materialized_literal_count = function_state.materialized_literal_count();
313 expected_property_count = function_state.expected_property_count(); 304 expected_property_count = function_state.expected_property_count();
314 handler_count = function_state.handler_count(); 305 handler_count = function_state.handler_count();
315 } 306 }
316 307
317 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 308 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
318 name, ast_value_factory(), function_scope, body, 309 name, ast_value_factory(), function_scope, body,
(...skipping 2309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2628 Expect(Token::RETURN, CHECK_OK); 2619 Expect(Token::RETURN, CHECK_OK);
2629 Scanner::Location loc = scanner()->location(); 2620 Scanner::Location loc = scanner()->location();
2630 2621
2631 Token::Value tok = peek(); 2622 Token::Value tok = peek();
2632 Statement* result; 2623 Statement* result;
2633 Expression* return_value; 2624 Expression* return_value;
2634 if (scanner()->HasAnyLineTerminatorBeforeNext() || 2625 if (scanner()->HasAnyLineTerminatorBeforeNext() ||
2635 tok == Token::SEMICOLON || 2626 tok == Token::SEMICOLON ||
2636 tok == Token::RBRACE || 2627 tok == Token::RBRACE ||
2637 tok == Token::EOS) { 2628 tok == Token::EOS) {
2638 if (FLAG_experimental_classes && 2629 if (IsSubclassConstructor(function_state_->kind())) {
2639 IsSubclassConstructor(function_state_->kind())) {
2640 return_value = ThisExpression(scope_, factory(), loc.beg_pos); 2630 return_value = ThisExpression(scope_, factory(), loc.beg_pos);
2641 } else { 2631 } else {
2642 return_value = GetLiteralUndefined(position()); 2632 return_value = GetLiteralUndefined(position());
2643 } 2633 }
2644 } else { 2634 } else {
2645 return_value = ParseExpression(true, CHECK_OK); 2635 return_value = ParseExpression(true, CHECK_OK);
2646 } 2636 }
2647 ExpectSemicolon(CHECK_OK); 2637 ExpectSemicolon(CHECK_OK);
2648 2638
2649 if (is_generator()) { 2639 if (is_generator()) {
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
3915 DCHECK(log_); 3905 DCHECK(log_);
3916 // Position right after terminal '}'. 3906 // Position right after terminal '}'.
3917 int body_end = scanner()->location().end_pos; 3907 int body_end = scanner()->location().end_pos;
3918 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count, 3908 log_->LogFunction(function_block_pos, body_end, *materialized_literal_count,
3919 *expected_property_count, scope_->language_mode()); 3909 *expected_property_count, scope_->language_mode());
3920 } 3910 }
3921 } 3911 }
3922 3912
3923 3913
3924 void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) { 3914 void Parser::AddAssertIsConstruct(ZoneList<Statement*>* body, int pos) {
3925 if (!FLAG_experimental_classes) return;
3926
3927 ZoneList<Expression*>* arguments = 3915 ZoneList<Expression*>* arguments =
3928 new (zone()) ZoneList<Expression*>(0, zone()); 3916 new (zone()) ZoneList<Expression*>(0, zone());
3929 CallRuntime* construct_check = factory()->NewCallRuntime( 3917 CallRuntime* construct_check = factory()->NewCallRuntime(
3930 ast_value_factory()->is_construct_call_string(), 3918 ast_value_factory()->is_construct_call_string(),
3931 Runtime::FunctionForId(Runtime::kInlineIsConstructCall), arguments, pos); 3919 Runtime::FunctionForId(Runtime::kInlineIsConstructCall), arguments, pos);
3932 CallRuntime* non_callable_error = factory()->NewCallRuntime( 3920 CallRuntime* non_callable_error = factory()->NewCallRuntime(
3933 ast_value_factory()->empty_string(), 3921 ast_value_factory()->empty_string(),
3934 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError), 3922 Runtime::FunctionForId(Runtime::kThrowConstructorNonCallableError),
3935 arguments, pos); 3923 arguments, pos);
3936 IfStatement* if_statement = factory()->NewIfStatement( 3924 IfStatement* if_statement = factory()->NewIfStatement(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
3993 VariableProxy* get_proxy = factory()->NewVariableProxy( 3981 VariableProxy* get_proxy = factory()->NewVariableProxy(
3994 function_state_->generator_object_variable()); 3982 function_state_->generator_object_variable());
3995 Expression* undefined = 3983 Expression* undefined =
3996 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); 3984 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition);
3997 Yield* yield = factory()->NewYield(get_proxy, undefined, Yield::kFinal, 3985 Yield* yield = factory()->NewYield(get_proxy, undefined, Yield::kFinal,
3998 RelocInfo::kNoPosition); 3986 RelocInfo::kNoPosition);
3999 body->Add(factory()->NewExpressionStatement( 3987 body->Add(factory()->NewExpressionStatement(
4000 yield, RelocInfo::kNoPosition), zone()); 3988 yield, RelocInfo::kNoPosition), zone());
4001 } 3989 }
4002 3990
4003 if (FLAG_experimental_classes && IsSubclassConstructor(kind)) { 3991 if (IsSubclassConstructor(kind)) {
4004 body->Add( 3992 body->Add(
4005 factory()->NewReturnStatement( 3993 factory()->NewReturnStatement(
4006 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition), 3994 this->ThisExpression(scope_, factory(), RelocInfo::kNoPosition),
4007 RelocInfo::kNoPosition), 3995 RelocInfo::kNoPosition),
4008 zone()); 3996 zone());
4009 } 3997 }
4010 3998
4011 Expect(Token::RBRACE, CHECK_OK); 3999 Expect(Token::RBRACE, CHECK_OK);
4012 scope_->set_end_position(scanner()->location().end_pos); 4000 scope_->set_end_position(scanner()->location().end_pos);
4013 4001
(...skipping 1456 matching lines...) Expand 10 before | Expand all | Expand 10 after
5470 } else { 5458 } else {
5471 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5459 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5472 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5460 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5473 raw_string->length()); 5461 raw_string->length());
5474 } 5462 }
5475 } 5463 }
5476 5464
5477 return running_hash; 5465 return running_hash;
5478 } 5466 }
5479 } } // namespace v8::internal 5467 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | src/ppc/full-codegen-ppc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698