| 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 3726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 } | 3737 } |
| 3738 | 3738 |
| 3739 | 3739 |
| 3740 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { | 3740 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
| 3741 if (expression->AsLiteral() != NULL) return true; | 3741 if (expression->AsLiteral() != NULL) return true; |
| 3742 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); | 3742 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); |
| 3743 return lit != NULL && lit->is_simple(); | 3743 return lit != NULL && lit->is_simple(); |
| 3744 } | 3744 } |
| 3745 | 3745 |
| 3746 | 3746 |
| 3747 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { | 3747 Handle<FixedArray> CompileTimeValue::GetValue(Isolate* isolate, |
| 3748 Factory* factory = Isolate::Current()->factory(); | 3748 Expression* expression) { |
| 3749 Factory* factory = isolate->factory(); |
| 3749 ASSERT(IsCompileTimeValue(expression)); | 3750 ASSERT(IsCompileTimeValue(expression)); |
| 3750 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); | 3751 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); |
| 3751 ObjectLiteral* object_literal = expression->AsObjectLiteral(); | 3752 ObjectLiteral* object_literal = expression->AsObjectLiteral(); |
| 3752 if (object_literal != NULL) { | 3753 if (object_literal != NULL) { |
| 3753 ASSERT(object_literal->is_simple()); | 3754 ASSERT(object_literal->is_simple()); |
| 3754 if (object_literal->fast_elements()) { | 3755 if (object_literal->fast_elements()) { |
| 3755 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); | 3756 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); |
| 3756 } else { | 3757 } else { |
| 3757 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS)); | 3758 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_SLOW_ELEMENTS)); |
| 3758 } | 3759 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3777 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { | 3778 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { |
| 3778 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); | 3779 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); |
| 3779 } | 3780 } |
| 3780 | 3781 |
| 3781 | 3782 |
| 3782 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { | 3783 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { |
| 3783 if (expression->AsLiteral() != NULL) { | 3784 if (expression->AsLiteral() != NULL) { |
| 3784 return expression->AsLiteral()->value(); | 3785 return expression->AsLiteral()->value(); |
| 3785 } | 3786 } |
| 3786 if (CompileTimeValue::IsCompileTimeValue(expression)) { | 3787 if (CompileTimeValue::IsCompileTimeValue(expression)) { |
| 3787 return CompileTimeValue::GetValue(expression); | 3788 return CompileTimeValue::GetValue(isolate(), expression); |
| 3788 } | 3789 } |
| 3789 return isolate()->factory()->uninitialized_value(); | 3790 return isolate()->factory()->uninitialized_value(); |
| 3790 } | 3791 } |
| 3791 | 3792 |
| 3792 | 3793 |
| 3793 // Validation per 11.1.5 Object Initialiser | 3794 // Validation per 11.1.5 Object Initialiser |
| 3794 class ObjectLiteralPropertyChecker { | 3795 class ObjectLiteralPropertyChecker { |
| 3795 public: | 3796 public: |
| 3796 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : | 3797 ObjectLiteralPropertyChecker(Parser* parser, LanguageMode language_mode) : |
| 3797 props_(Literal::Match), | 3798 props_(Literal::Match), |
| (...skipping 1218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5016 | 5017 |
| 5017 | 5018 |
| 5018 // ---------------------------------------------------------------------------- | 5019 // ---------------------------------------------------------------------------- |
| 5019 // Regular expressions | 5020 // Regular expressions |
| 5020 | 5021 |
| 5021 | 5022 |
| 5022 RegExpParser::RegExpParser(FlatStringReader* in, | 5023 RegExpParser::RegExpParser(FlatStringReader* in, |
| 5023 Handle<String>* error, | 5024 Handle<String>* error, |
| 5024 bool multiline, | 5025 bool multiline, |
| 5025 Zone* zone) | 5026 Zone* zone) |
| 5026 : isolate_(Isolate::Current()), | 5027 : isolate_(zone->isolate()), |
| 5027 zone_(zone), | 5028 zone_(zone), |
| 5028 error_(error), | 5029 error_(error), |
| 5029 captures_(NULL), | 5030 captures_(NULL), |
| 5030 in_(in), | 5031 in_(in), |
| 5031 current_(kEndMarker), | 5032 current_(kEndMarker), |
| 5032 next_pos_(0), | 5033 next_pos_(0), |
| 5033 capture_count_(0), | 5034 capture_count_(0), |
| 5034 has_more_(true), | 5035 has_more_(true), |
| 5035 multiline_(multiline), | 5036 multiline_(multiline), |
| 5036 simple_(false), | 5037 simple_(false), |
| (...skipping 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5888 input = *data; | 5889 input = *data; |
| 5889 result = (result << 7) | (input & 0x7f); | 5890 result = (result << 7) | (input & 0x7f); |
| 5890 data++; | 5891 data++; |
| 5891 } | 5892 } |
| 5892 *source = data; | 5893 *source = data; |
| 5893 return result; | 5894 return result; |
| 5894 } | 5895 } |
| 5895 | 5896 |
| 5896 | 5897 |
| 5897 // Create a Scanner for the preparser to use as input, and preparse the source. | 5898 // Create a Scanner for the preparser to use as input, and preparse the source. |
| 5898 ScriptDataImpl* PreParserApi::PreParse(Utf16CharacterStream* source) { | 5899 ScriptDataImpl* PreParserApi::PreParse(Isolate* isolate, |
| 5900 Utf16CharacterStream* source) { |
| 5899 CompleteParserRecorder recorder; | 5901 CompleteParserRecorder recorder; |
| 5900 Isolate* isolate = Isolate::Current(); | |
| 5901 HistogramTimerScope timer(isolate->counters()->pre_parse()); | 5902 HistogramTimerScope timer(isolate->counters()->pre_parse()); |
| 5902 Scanner scanner(isolate->unicode_cache()); | 5903 Scanner scanner(isolate->unicode_cache()); |
| 5903 intptr_t stack_limit = isolate->stack_guard()->real_climit(); | 5904 intptr_t stack_limit = isolate->stack_guard()->real_climit(); |
| 5904 preparser::PreParser preparser(&scanner, &recorder, stack_limit); | 5905 preparser::PreParser preparser(&scanner, &recorder, stack_limit); |
| 5905 preparser.set_allow_lazy(true); | 5906 preparser.set_allow_lazy(true); |
| 5906 preparser.set_allow_generators(FLAG_harmony_generators); | 5907 preparser.set_allow_generators(FLAG_harmony_generators); |
| 5907 preparser.set_allow_for_of(FLAG_harmony_iteration); | 5908 preparser.set_allow_for_of(FLAG_harmony_iteration); |
| 5908 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping); | 5909 preparser.set_allow_harmony_scoping(FLAG_harmony_scoping); |
| 5909 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 5910 preparser.set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
| 5910 scanner.Initialize(source); | 5911 scanner.Initialize(source); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5970 ASSERT(info()->isolate()->has_pending_exception()); | 5971 ASSERT(info()->isolate()->has_pending_exception()); |
| 5971 } else { | 5972 } else { |
| 5972 result = ParseProgram(); | 5973 result = ParseProgram(); |
| 5973 } | 5974 } |
| 5974 } | 5975 } |
| 5975 info()->SetFunction(result); | 5976 info()->SetFunction(result); |
| 5976 return (result != NULL); | 5977 return (result != NULL); |
| 5977 } | 5978 } |
| 5978 | 5979 |
| 5979 } } // namespace v8::internal | 5980 } } // namespace v8::internal |
| OLD | NEW |