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