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

Side by Side Diff: src/parsing/parser.cc

Issue 2324803002: [Parser] Avoid on-the-fly internalization for natives_syntax. (Closed)
Patch Set: Created 4 years, 3 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.h ('k') | src/runtime/runtime.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 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/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 Expression* Parser::NewV8Intrinsic(const AstRawString* name, 509 Expression* Parser::NewV8Intrinsic(const AstRawString* name,
510 ZoneList<Expression*>* args, int pos, 510 ZoneList<Expression*>* args, int pos,
511 bool* ok) { 511 bool* ok) {
512 if (extension_ != nullptr) { 512 if (extension_ != nullptr) {
513 // The extension structures are only accessible while parsing the 513 // The extension structures are only accessible while parsing the
514 // very first time, not when reparsing because of lazy compilation. 514 // very first time, not when reparsing because of lazy compilation.
515 GetClosureScope()->ForceEagerCompilation(); 515 GetClosureScope()->ForceEagerCompilation();
516 } 516 }
517 517
518 const Runtime::Function* function = Runtime::FunctionForName(name->string()); 518 DCHECK(name->is_one_byte());
519 const Runtime::Function* function =
520 Runtime::FunctionForName(name->raw_data(), name->length());
519 521
520 if (function != nullptr) { 522 if (function != nullptr) {
521 // Check for possible name clash. 523 // Check for possible name clash.
522 DCHECK_EQ(Context::kNotFound, 524 DCHECK_EQ(Context::kNotFound,
523 Context::IntrinsicIndexForName(name->string())); 525 Context::IntrinsicIndexForName(name->raw_data(), name->length()));
524 // Check for built-in IS_VAR macro. 526 // Check for built-in IS_VAR macro.
525 if (function->function_id == Runtime::kIS_VAR) { 527 if (function->function_id == Runtime::kIS_VAR) {
526 DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type); 528 DCHECK_EQ(Runtime::RUNTIME, function->intrinsic_type);
527 // %IS_VAR(x) evaluates to x if x is a variable, 529 // %IS_VAR(x) evaluates to x if x is a variable,
528 // leads to a parse error otherwise. Could be implemented as an 530 // leads to a parse error otherwise. Could be implemented as an
529 // inline function %_IS_VAR(x) to eliminate this special case. 531 // inline function %_IS_VAR(x) to eliminate this special case.
530 if (args->length() == 1 && args->at(0)->AsVariableProxy() != nullptr) { 532 if (args->length() == 1 && args->at(0)->AsVariableProxy() != nullptr) {
531 return args->at(0); 533 return args->at(0);
532 } else { 534 } else {
533 ReportMessage(MessageTemplate::kNotIsvar); 535 ReportMessage(MessageTemplate::kNotIsvar);
534 *ok = false; 536 *ok = false;
535 return nullptr; 537 return nullptr;
536 } 538 }
537 } 539 }
538 540
539 // Check that the expected number of arguments are being passed. 541 // Check that the expected number of arguments are being passed.
540 if (function->nargs != -1 && function->nargs != args->length()) { 542 if (function->nargs != -1 && function->nargs != args->length()) {
541 ReportMessage(MessageTemplate::kRuntimeWrongNumArgs); 543 ReportMessage(MessageTemplate::kRuntimeWrongNumArgs);
542 *ok = false; 544 *ok = false;
543 return nullptr; 545 return nullptr;
544 } 546 }
545 547
546 return factory()->NewCallRuntime(function, args, pos); 548 return factory()->NewCallRuntime(function, args, pos);
547 } 549 }
548 550
549 int context_index = Context::IntrinsicIndexForName(name->string()); 551 int context_index =
552 Context::IntrinsicIndexForName(name->raw_data(), name->length());
550 553
551 // Check that the function is defined. 554 // Check that the function is defined.
552 if (context_index == Context::kNotFound) { 555 if (context_index == Context::kNotFound) {
553 ReportMessage(MessageTemplate::kNotDefined, name); 556 ReportMessage(MessageTemplate::kNotDefined, name);
554 *ok = false; 557 *ok = false;
555 return nullptr; 558 return nullptr;
556 } 559 }
557 560
558 return factory()->NewCallRuntime(context_index, args, pos); 561 return factory()->NewCallRuntime(context_index, args, pos);
559 } 562 }
(...skipping 3869 matching lines...) Expand 10 before | Expand all | Expand 10 after
4429 } 4432 }
4430 4433
4431 4434
4432 bool Parser::Parse(ParseInfo* info) { 4435 bool Parser::Parse(ParseInfo* info) {
4433 DCHECK(info->literal() == NULL); 4436 DCHECK(info->literal() == NULL);
4434 FunctionLiteral* result = NULL; 4437 FunctionLiteral* result = NULL;
4435 // Ok to use Isolate here; this function is only called in the main thread. 4438 // Ok to use Isolate here; this function is only called in the main thread.
4436 DCHECK(parsing_on_main_thread_); 4439 DCHECK(parsing_on_main_thread_);
4437 Isolate* isolate = info->isolate(); 4440 Isolate* isolate = info->isolate();
4438 pre_parse_timer_ = isolate->counters()->pre_parse(); 4441 pre_parse_timer_ = isolate->counters()->pre_parse();
4439 if (FLAG_trace_parse || allow_natives() || extension_ != NULL) {
4440 // If intrinsics are allowed, the Parser cannot operate independent of the
4441 // V8 heap because of Runtime. Tell the string table to internalize strings
4442 // and values right after they're created.
4443 ast_value_factory()->Internalize(isolate);
4444 }
4445 4442
4446 if (info->is_lazy()) { 4443 if (info->is_lazy()) {
4447 DCHECK(!info->is_eval()); 4444 DCHECK(!info->is_eval());
4448 if (info->shared_info()->is_function()) { 4445 if (info->shared_info()->is_function()) {
4449 result = ParseLazy(isolate, info); 4446 result = ParseLazy(isolate, info);
4450 } else { 4447 } else {
4451 result = ParseProgram(isolate, info); 4448 result = ParseProgram(isolate, info);
4452 } 4449 }
4453 } else { 4450 } else {
4454 SetCachedData(info); 4451 SetCachedData(info);
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
6007 node->Print(Isolate::Current()); 6004 node->Print(Isolate::Current());
6008 } 6005 }
6009 #endif // DEBUG 6006 #endif // DEBUG
6010 6007
6011 #undef CHECK_OK 6008 #undef CHECK_OK
6012 #undef CHECK_OK_VOID 6009 #undef CHECK_OK_VOID
6013 #undef CHECK_FAILED 6010 #undef CHECK_FAILED
6014 6011
6015 } // namespace internal 6012 } // namespace internal
6016 } // namespace v8 6013 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698