OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { | 208 Handle<String> Parser::LookupCachedSymbol(int symbol_id) { |
209 // Make sure the cache is large enough to hold the symbol identifier. | 209 // Make sure the cache is large enough to hold the symbol identifier. |
210 if (symbol_cache_.length() <= symbol_id) { | 210 if (symbol_cache_.length() <= symbol_id) { |
211 // Increase length to index + 1. | 211 // Increase length to index + 1. |
212 symbol_cache_.AddBlock(Handle<String>::null(), | 212 symbol_cache_.AddBlock(Handle<String>::null(), |
213 symbol_id + 1 - symbol_cache_.length(), zone()); | 213 symbol_id + 1 - symbol_cache_.length(), zone()); |
214 } | 214 } |
215 Handle<String> result = symbol_cache_.at(symbol_id); | 215 Handle<String> result = symbol_cache_.at(symbol_id); |
216 if (result.is_null()) { | 216 if (result.is_null()) { |
217 result = scanner()->AllocateInternalizedString(isolate_); | 217 result = scanner()->AllocateInternalizedString(isolate_); |
218 ASSERT(!result.is_null()); | |
219 symbol_cache_.at(symbol_id) = result; | 218 symbol_cache_.at(symbol_id) = result; |
220 return result; | 219 return result; |
221 } | 220 } |
222 isolate()->counters()->total_preparse_symbols_skipped()->Increment(); | 221 isolate()->counters()->total_preparse_symbols_skipped()->Increment(); |
223 return result; | 222 return result; |
224 } | 223 } |
225 | 224 |
226 | 225 |
227 FunctionEntry ScriptDataImpl::GetFunctionEntry(int start) { | 226 FunctionEntry ScriptDataImpl::GetFunctionEntry(int start) { |
228 // The current pre-data entry must be a FunctionEntry with the given | 227 // The current pre-data entry must be a FunctionEntry with the given |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 // and we want to report the stack overflow later. | 608 // and we want to report the stack overflow later. |
610 return; | 609 return; |
611 } | 610 } |
612 MessageLocation location(parser_->script_, | 611 MessageLocation location(parser_->script_, |
613 source_location.beg_pos, | 612 source_location.beg_pos, |
614 source_location.end_pos); | 613 source_location.end_pos); |
615 Factory* factory = parser_->isolate()->factory(); | 614 Factory* factory = parser_->isolate()->factory(); |
616 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); | 615 Handle<FixedArray> elements = factory->NewFixedArray(args.length()); |
617 for (int i = 0; i < args.length(); i++) { | 616 for (int i = 0; i < args.length(); i++) { |
618 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i])); | 617 Handle<String> arg_string = factory->NewStringFromUtf8(CStrVector(args[i])); |
619 ASSERT(!arg_string.is_null()); | |
620 elements->set(i, *arg_string); | 618 elements->set(i, *arg_string); |
621 } | 619 } |
622 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); | 620 Handle<JSArray> array = factory->NewJSArrayWithElements(elements); |
623 Handle<Object> result = is_reference_error | 621 Handle<Object> result = is_reference_error |
624 ? factory->NewReferenceError(message, array) | 622 ? factory->NewReferenceError(message, array) |
625 : factory->NewSyntaxError(message, array); | 623 : factory->NewSyntaxError(message, array); |
626 parser_->isolate()->Throw(*result, &location); | 624 parser_->isolate()->Throw(*result, &location); |
627 } | 625 } |
628 | 626 |
629 | 627 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 // If there is no symbol data, -1 will be returned. | 665 // If there is no symbol data, -1 will be returned. |
668 if (symbol_id >= 0 && | 666 if (symbol_id >= 0 && |
669 symbol_id < (*parser_->cached_data())->symbol_count()) { | 667 symbol_id < (*parser_->cached_data())->symbol_count()) { |
670 return parser_->LookupCachedSymbol(symbol_id); | 668 return parser_->LookupCachedSymbol(symbol_id); |
671 } | 669 } |
672 } else if (parser_->cached_data_mode() == PRODUCE_CACHED_DATA) { | 670 } else if (parser_->cached_data_mode() == PRODUCE_CACHED_DATA) { |
673 if (parser_->log_->ShouldLogSymbols()) { | 671 if (parser_->log_->ShouldLogSymbols()) { |
674 parser_->scanner()->LogSymbol(parser_->log_, parser_->position()); | 672 parser_->scanner()->LogSymbol(parser_->log_, parser_->position()); |
675 } | 673 } |
676 } | 674 } |
677 Handle<String> result = | 675 return parser_->scanner()->AllocateInternalizedString(parser_->isolate_); |
678 parser_->scanner()->AllocateInternalizedString(parser_->isolate_); | |
679 ASSERT(!result.is_null()); | |
680 return result; | |
681 } | 676 } |
682 | 677 |
683 | 678 |
684 Handle<String> ParserTraits::NextLiteralString(Scanner* scanner, | 679 Handle<String> ParserTraits::NextLiteralString(Scanner* scanner, |
685 PretenureFlag tenured) { | 680 PretenureFlag tenured) { |
686 return scanner->AllocateNextLiteralString(parser_->isolate(), tenured); | 681 return scanner->AllocateNextLiteralString(parser_->isolate(), tenured); |
687 } | 682 } |
688 | 683 |
689 | 684 |
690 Expression* ParserTraits::ThisExpression( | 685 Expression* ParserTraits::ThisExpression( |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 // In harmony we treat re-declarations as early errors. See | 1702 // In harmony we treat re-declarations as early errors. See |
1708 // ES5 16 for a definition of early errors. | 1703 // ES5 16 for a definition of early errors. |
1709 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); | 1704 SmartArrayPointer<char> c_string = name->ToCString(DISALLOW_NULLS); |
1710 const char* elms[2] = { "Variable", c_string.get() }; | 1705 const char* elms[2] = { "Variable", c_string.get() }; |
1711 Vector<const char*> args(elms, 2); | 1706 Vector<const char*> args(elms, 2); |
1712 ReportMessage("redeclaration", args); | 1707 ReportMessage("redeclaration", args); |
1713 *ok = false; | 1708 *ok = false; |
1714 return; | 1709 return; |
1715 } | 1710 } |
1716 Handle<String> message_string = | 1711 Handle<String> message_string = |
1717 isolate()->factory()->InternalizeOneByteString( | 1712 isolate()->factory()->NewStringFromUtf8(CStrVector("Variable"), |
1718 STATIC_ASCII_VECTOR("Variable")); | 1713 TENURED); |
1719 Expression* expression = | 1714 Expression* expression = |
1720 NewThrowTypeError(isolate()->factory()->redeclaration_string(), | 1715 NewThrowTypeError(isolate()->factory()->redeclaration_string(), |
1721 message_string, name); | 1716 message_string, name); |
1722 declaration_scope->SetIllegalRedeclaration(expression); | 1717 declaration_scope->SetIllegalRedeclaration(expression); |
1723 } | 1718 } |
1724 } | 1719 } |
1725 | 1720 |
1726 // We add a declaration node for every declaration. The compiler | 1721 // We add a declaration node for every declaration. The compiler |
1727 // will only generate code if necessary. In particular, declarations | 1722 // will only generate code if necessary. In particular, declarations |
1728 // for inner local variables that do not represent functions won't | 1723 // for inner local variables that do not represent functions won't |
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3814 | 3809 |
3815 | 3810 |
3816 bool RegExpParser::simple() { | 3811 bool RegExpParser::simple() { |
3817 return simple_; | 3812 return simple_; |
3818 } | 3813 } |
3819 | 3814 |
3820 | 3815 |
3821 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { | 3816 RegExpTree* RegExpParser::ReportError(Vector<const char> message) { |
3822 failed_ = true; | 3817 failed_ = true; |
3823 *error_ = isolate()->factory()->NewStringFromAscii(message, NOT_TENURED); | 3818 *error_ = isolate()->factory()->NewStringFromAscii(message, NOT_TENURED); |
3824 ASSERT(!error_->is_null()); | |
3825 // Zip to the end to make sure the no more input is read. | 3819 // Zip to the end to make sure the no more input is read. |
3826 current_ = kEndMarker; | 3820 current_ = kEndMarker; |
3827 next_pos_ = in()->length(); | 3821 next_pos_ = in()->length(); |
3828 return NULL; | 3822 return NULL; |
3829 } | 3823 } |
3830 | 3824 |
3831 | 3825 |
3832 // Pattern :: | 3826 // Pattern :: |
3833 // Disjunction | 3827 // Disjunction |
3834 RegExpTree* RegExpParser::ParsePattern() { | 3828 RegExpTree* RegExpParser::ParsePattern() { |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4697 ASSERT(info()->isolate()->has_pending_exception()); | 4691 ASSERT(info()->isolate()->has_pending_exception()); |
4698 } else { | 4692 } else { |
4699 result = ParseProgram(); | 4693 result = ParseProgram(); |
4700 } | 4694 } |
4701 } | 4695 } |
4702 info()->SetFunction(result); | 4696 info()->SetFunction(result); |
4703 return (result != NULL); | 4697 return (result != NULL); |
4704 } | 4698 } |
4705 | 4699 |
4706 } } // namespace v8::internal | 4700 } } // namespace v8::internal |
OLD | NEW |