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

Side by Side Diff: src/parser.cc

Issue 335373002: Fix: AstValueFactory must be internalized before ThrowPendingError. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added test Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/ast-value-factory.h ('k') | test/cctest/test-parsing.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/bootstrapper.h" 9 #include "src/bootstrapper.h"
10 #include "src/char-predicates-inl.h" 10 #include "src/char-predicates-inl.h"
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 904 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
905 if (body->length() != 1 || 905 if (body->length() != 1 ||
906 !body->at(0)->IsExpressionStatement() || 906 !body->at(0)->IsExpressionStatement() ||
907 !body->at(0)->AsExpressionStatement()-> 907 !body->at(0)->AsExpressionStatement()->
908 expression()->IsFunctionLiteral()) { 908 expression()->IsFunctionLiteral()) {
909 ReportMessage("single_function_literal"); 909 ReportMessage("single_function_literal");
910 ok = false; 910 ok = false;
911 } 911 }
912 } 912 }
913 913
914 ast_value_factory_->Internalize(isolate());
914 if (ok) { 915 if (ok) {
915 result = factory()->NewFunctionLiteral( 916 result = factory()->NewFunctionLiteral(
916 ast_value_factory_->empty_string(), 917 ast_value_factory_->empty_string(),
917 ast_value_factory_, 918 ast_value_factory_,
918 scope_, 919 scope_,
919 body, 920 body,
920 function_state.materialized_literal_count(), 921 function_state.materialized_literal_count(),
921 function_state.expected_property_count(), 922 function_state.expected_property_count(),
922 function_state.handler_count(), 923 function_state.handler_count(),
923 0, 924 0,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 function_type, 1025 function_type,
1025 FunctionLiteral::NORMAL_ARITY, 1026 FunctionLiteral::NORMAL_ARITY,
1026 &ok); 1027 &ok);
1027 // Make sure the results agree. 1028 // Make sure the results agree.
1028 ASSERT(ok == (result != NULL)); 1029 ASSERT(ok == (result != NULL));
1029 } 1030 }
1030 1031
1031 // Make sure the target stack is empty. 1032 // Make sure the target stack is empty.
1032 ASSERT(target_stack_ == NULL); 1033 ASSERT(target_stack_ == NULL);
1033 1034
1035 ast_value_factory_->Internalize(isolate());
1034 if (result == NULL) { 1036 if (result == NULL) {
1035 if (stack_overflow()) { 1037 if (stack_overflow()) {
1036 isolate()->StackOverflow(); 1038 isolate()->StackOverflow();
1037 } else { 1039 } else {
1038 ThrowPendingError(); 1040 ThrowPendingError();
1039 } 1041 }
1040 } else { 1042 } else {
1041 Handle<String> inferred_name(shared_info->inferred_name()); 1043 Handle<String> inferred_name(shared_info->inferred_name());
1042 result->set_inferred_name(inferred_name); 1044 result->set_inferred_name(inferred_name);
1043 } 1045 }
(...skipping 2833 matching lines...) Expand 10 before | Expand all | Expand 10 after
3877 // target stack has been used from the top of the target stack. Add 3879 // target stack has been used from the top of the target stack. Add
3878 // the break target to any TargetCollectors passed on the stack. 3880 // the break target to any TargetCollectors passed on the stack.
3879 for (Target* t = target_stack_; t != stop; t = t->previous()) { 3881 for (Target* t = target_stack_; t != stop; t = t->previous()) {
3880 TargetCollector* collector = t->node()->AsTargetCollector(); 3882 TargetCollector* collector = t->node()->AsTargetCollector();
3881 if (collector != NULL) collector->AddTarget(target, zone()); 3883 if (collector != NULL) collector->AddTarget(target, zone());
3882 } 3884 }
3883 } 3885 }
3884 3886
3885 3887
3886 void Parser::ThrowPendingError() { 3888 void Parser::ThrowPendingError() {
3889 ASSERT(ast_value_factory_->IsInternalized());
3887 if (has_pending_error_) { 3890 if (has_pending_error_) {
3888 MessageLocation location(script_, 3891 MessageLocation location(script_,
3889 pending_error_location_.beg_pos, 3892 pending_error_location_.beg_pos,
3890 pending_error_location_.end_pos); 3893 pending_error_location_.end_pos);
3891 Factory* factory = isolate()->factory(); 3894 Factory* factory = isolate()->factory();
3892 bool has_arg = 3895 bool has_arg =
3893 pending_error_arg_ != NULL || pending_error_char_arg_ != NULL; 3896 pending_error_arg_ != NULL || pending_error_char_arg_ != NULL;
3894 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0); 3897 Handle<FixedArray> elements = factory->NewFixedArray(has_arg ? 1 : 0);
3895 if (pending_error_arg_ != NULL) { 3898 if (pending_error_arg_ != NULL) {
3896 Handle<String> arg_string = pending_error_arg_->string(); 3899 Handle<String> arg_string = pending_error_arg_->string();
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 ParserTraits::ReportMessageAt(loc, message, arg, 4840 ParserTraits::ReportMessageAt(loc, message, arg,
4838 cached_data->IsReferenceError()); 4841 cached_data->IsReferenceError());
4839 DeleteArray(message); 4842 DeleteArray(message);
4840 DeleteArray(arg); 4843 DeleteArray(arg);
4841 ASSERT(info()->isolate()->has_pending_exception()); 4844 ASSERT(info()->isolate()->has_pending_exception());
4842 } else { 4845 } else {
4843 result = ParseProgram(); 4846 result = ParseProgram();
4844 } 4847 }
4845 } 4848 }
4846 info()->SetFunction(result); 4849 info()->SetFunction(result);
4847 ast_value_factory_->Internalize(isolate()); 4850 ASSERT(ast_value_factory_->IsInternalized());
4848 // info takes ownership of ast_value_factory_. 4851 // info takes ownership of ast_value_factory_.
4849 if (info()->ast_value_factory() == NULL) { 4852 if (info()->ast_value_factory() == NULL) {
4850 info()->SetAstValueFactory(ast_value_factory_); 4853 info()->SetAstValueFactory(ast_value_factory_);
4851 } 4854 }
4852 ast_value_factory_ = NULL; 4855 ast_value_factory_ = NULL;
4853 return (result != NULL); 4856 return (result != NULL);
4854 } 4857 }
4855 4858
4856 } } // namespace v8::internal 4859 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast-value-factory.h ('k') | test/cctest/test-parsing.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698