| 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 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); | 559 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
| 560 set_allow_modules(!info->is_native() && FLAG_harmony_modules); | 560 set_allow_modules(!info->is_native() && FLAG_harmony_modules); |
| 561 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); | 561 set_allow_natives_syntax(FLAG_allow_natives_syntax || info->is_native()); |
| 562 set_allow_lazy(false); // Must be explicitly enabled. | 562 set_allow_lazy(false); // Must be explicitly enabled. |
| 563 set_allow_generators(FLAG_harmony_generators); | 563 set_allow_generators(FLAG_harmony_generators); |
| 564 set_allow_for_of(FLAG_harmony_iteration); | 564 set_allow_for_of(FLAG_harmony_iteration); |
| 565 } | 565 } |
| 566 | 566 |
| 567 | 567 |
| 568 FunctionLiteral* Parser::ParseProgram() { | 568 FunctionLiteral* Parser::ParseProgram() { |
| 569 ZoneScope zone_scope(zone(), DONT_DELETE_ON_EXIT); | |
| 570 HistogramTimerScope timer(isolate()->counters()->parse()); | 569 HistogramTimerScope timer(isolate()->counters()->parse()); |
| 571 Handle<String> source(String::cast(script_->source())); | 570 Handle<String> source(String::cast(script_->source())); |
| 572 isolate()->counters()->total_parse_size()->Increment(source->length()); | 571 isolate()->counters()->total_parse_size()->Increment(source->length()); |
| 573 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; | 572 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; |
| 574 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); | 573 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
| 575 | 574 |
| 576 // Initialize parser state. | 575 // Initialize parser state. |
| 577 source->TryFlatten(); | 576 source->TryFlatten(); |
| 578 FunctionLiteral* result; | 577 FunctionLiteral* result; |
| 579 if (source->IsExternalTwoByteString()) { | 578 if (source->IsExternalTwoByteString()) { |
| 580 // Notice that the stream is destroyed at the end of the branch block. | 579 // Notice that the stream is destroyed at the end of the branch block. |
| 581 // The last line of the blocks can't be moved outside, even though they're | 580 // The last line of the blocks can't be moved outside, even though they're |
| 582 // identical calls. | 581 // identical calls. |
| 583 ExternalTwoByteStringUtf16CharacterStream stream( | 582 ExternalTwoByteStringUtf16CharacterStream stream( |
| 584 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); | 583 Handle<ExternalTwoByteString>::cast(source), 0, source->length()); |
| 585 scanner_.Initialize(&stream); | 584 scanner_.Initialize(&stream); |
| 586 result = DoParseProgram(info(), source, &zone_scope); | 585 result = DoParseProgram(info(), source); |
| 587 } else { | 586 } else { |
| 588 GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 587 GenericStringUtf16CharacterStream stream(source, 0, source->length()); |
| 589 scanner_.Initialize(&stream); | 588 scanner_.Initialize(&stream); |
| 590 result = DoParseProgram(info(), source, &zone_scope); | 589 result = DoParseProgram(info(), source); |
| 591 } | 590 } |
| 592 | 591 |
| 593 if (FLAG_trace_parse && result != NULL) { | 592 if (FLAG_trace_parse && result != NULL) { |
| 594 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 593 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
| 595 if (info()->is_eval()) { | 594 if (info()->is_eval()) { |
| 596 PrintF("[parsing eval"); | 595 PrintF("[parsing eval"); |
| 597 } else if (info()->script()->name()->IsString()) { | 596 } else if (info()->script()->name()->IsString()) { |
| 598 String* name = String::cast(info()->script()->name()); | 597 String* name = String::cast(info()->script()->name()); |
| 599 SmartArrayPointer<char> name_chars = name->ToCString(); | 598 SmartArrayPointer<char> name_chars = name->ToCString(); |
| 600 PrintF("[parsing script: %s", *name_chars); | 599 PrintF("[parsing script: %s", *name_chars); |
| 601 } else { | 600 } else { |
| 602 PrintF("[parsing script"); | 601 PrintF("[parsing script"); |
| 603 } | 602 } |
| 604 PrintF(" - took %0.3f ms]\n", ms); | 603 PrintF(" - took %0.3f ms]\n", ms); |
| 605 } | 604 } |
| 606 return result; | 605 return result; |
| 607 } | 606 } |
| 608 | 607 |
| 609 | 608 |
| 610 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, | 609 FunctionLiteral* Parser::DoParseProgram(CompilationInfo* info, |
| 611 Handle<String> source, | 610 Handle<String> source) { |
| 612 ZoneScope* zone_scope) { | |
| 613 ASSERT(top_scope_ == NULL); | 611 ASSERT(top_scope_ == NULL); |
| 614 ASSERT(target_stack_ == NULL); | 612 ASSERT(target_stack_ == NULL); |
| 615 if (pre_parse_data_ != NULL) pre_parse_data_->Initialize(); | 613 if (pre_parse_data_ != NULL) pre_parse_data_->Initialize(); |
| 616 | 614 |
| 617 Handle<String> no_name = isolate()->factory()->empty_string(); | 615 Handle<String> no_name = isolate()->factory()->empty_string(); |
| 618 | 616 |
| 619 FunctionLiteral* result = NULL; | 617 FunctionLiteral* result = NULL; |
| 620 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); | 618 { Scope* scope = NewScope(top_scope_, GLOBAL_SCOPE); |
| 621 info->SetGlobalScope(scope); | 619 info->SetGlobalScope(scope); |
| 622 if (!info->context().is_null()) { | 620 if (!info->context().is_null()) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 FunctionLiteral::kNotGenerator); | 681 FunctionLiteral::kNotGenerator); |
| 684 result->set_ast_properties(factory()->visitor()->ast_properties()); | 682 result->set_ast_properties(factory()->visitor()->ast_properties()); |
| 685 } else if (stack_overflow_) { | 683 } else if (stack_overflow_) { |
| 686 isolate()->StackOverflow(); | 684 isolate()->StackOverflow(); |
| 687 } | 685 } |
| 688 } | 686 } |
| 689 | 687 |
| 690 // Make sure the target stack is empty. | 688 // Make sure the target stack is empty. |
| 691 ASSERT(target_stack_ == NULL); | 689 ASSERT(target_stack_ == NULL); |
| 692 | 690 |
| 693 // If there was a syntax error we have to get rid of the AST | |
| 694 // and it is not safe to do so before the scope has been deleted. | |
| 695 if (result == NULL) zone_scope->DeleteOnExit(); | |
| 696 return result; | 691 return result; |
| 697 } | 692 } |
| 698 | 693 |
| 699 | 694 |
| 700 FunctionLiteral* Parser::ParseLazy() { | 695 FunctionLiteral* Parser::ParseLazy() { |
| 701 ZoneScope zone_scope(zone(), DONT_DELETE_ON_EXIT); | |
| 702 HistogramTimerScope timer(isolate()->counters()->parse_lazy()); | 696 HistogramTimerScope timer(isolate()->counters()->parse_lazy()); |
| 703 Handle<String> source(String::cast(script_->source())); | 697 Handle<String> source(String::cast(script_->source())); |
| 704 isolate()->counters()->total_parse_size()->Increment(source->length()); | 698 isolate()->counters()->total_parse_size()->Increment(source->length()); |
| 705 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; | 699 int64_t start = FLAG_trace_parse ? OS::Ticks() : 0; |
| 706 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); | 700 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); |
| 707 | 701 |
| 708 // Initialize parser state. | 702 // Initialize parser state. |
| 709 source->TryFlatten(); | 703 source->TryFlatten(); |
| 710 FunctionLiteral* result; | 704 FunctionLiteral* result; |
| 711 if (source->IsExternalTwoByteString()) { | 705 if (source->IsExternalTwoByteString()) { |
| 712 ExternalTwoByteStringUtf16CharacterStream stream( | 706 ExternalTwoByteStringUtf16CharacterStream stream( |
| 713 Handle<ExternalTwoByteString>::cast(source), | 707 Handle<ExternalTwoByteString>::cast(source), |
| 714 shared_info->start_position(), | 708 shared_info->start_position(), |
| 715 shared_info->end_position()); | 709 shared_info->end_position()); |
| 716 result = ParseLazy(&stream, &zone_scope); | 710 result = ParseLazy(&stream); |
| 717 } else { | 711 } else { |
| 718 GenericStringUtf16CharacterStream stream(source, | 712 GenericStringUtf16CharacterStream stream(source, |
| 719 shared_info->start_position(), | 713 shared_info->start_position(), |
| 720 shared_info->end_position()); | 714 shared_info->end_position()); |
| 721 result = ParseLazy(&stream, &zone_scope); | 715 result = ParseLazy(&stream); |
| 722 } | 716 } |
| 723 | 717 |
| 724 if (FLAG_trace_parse && result != NULL) { | 718 if (FLAG_trace_parse && result != NULL) { |
| 725 double ms = static_cast<double>(OS::Ticks() - start) / 1000; | 719 double ms = static_cast<double>(OS::Ticks() - start) / 1000; |
| 726 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); | 720 SmartArrayPointer<char> name_chars = result->debug_name()->ToCString(); |
| 727 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); | 721 PrintF("[parsing function: %s - took %0.3f ms]\n", *name_chars, ms); |
| 728 } | 722 } |
| 729 return result; | 723 return result; |
| 730 } | 724 } |
| 731 | 725 |
| 732 | 726 |
| 733 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source, | 727 FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) { |
| 734 ZoneScope* zone_scope) { | |
| 735 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); | 728 Handle<SharedFunctionInfo> shared_info = info()->shared_info(); |
| 736 scanner_.Initialize(source); | 729 scanner_.Initialize(source); |
| 737 ASSERT(top_scope_ == NULL); | 730 ASSERT(top_scope_ == NULL); |
| 738 ASSERT(target_stack_ == NULL); | 731 ASSERT(target_stack_ == NULL); |
| 739 | 732 |
| 740 Handle<String> name(String::cast(shared_info->name())); | 733 Handle<String> name(String::cast(shared_info->name())); |
| 741 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); | 734 fni_ = new(zone()) FuncNameInferrer(isolate(), zone()); |
| 742 fni_->PushEnclosingName(name); | 735 fni_->PushEnclosingName(name); |
| 743 | 736 |
| 744 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); | 737 ParsingModeScope parsing_mode(this, PARSE_EAGERLY); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 772 RelocInfo::kNoPosition, | 765 RelocInfo::kNoPosition, |
| 773 function_type, | 766 function_type, |
| 774 &ok); | 767 &ok); |
| 775 // Make sure the results agree. | 768 // Make sure the results agree. |
| 776 ASSERT(ok == (result != NULL)); | 769 ASSERT(ok == (result != NULL)); |
| 777 } | 770 } |
| 778 | 771 |
| 779 // Make sure the target stack is empty. | 772 // Make sure the target stack is empty. |
| 780 ASSERT(target_stack_ == NULL); | 773 ASSERT(target_stack_ == NULL); |
| 781 | 774 |
| 782 // If there was a stack overflow we have to get rid of AST and it is | |
| 783 // not safe to do before scope has been deleted. | |
| 784 if (result == NULL) { | 775 if (result == NULL) { |
| 785 zone_scope->DeleteOnExit(); | |
| 786 if (stack_overflow_) isolate()->StackOverflow(); | 776 if (stack_overflow_) isolate()->StackOverflow(); |
| 787 } else { | 777 } else { |
| 788 Handle<String> inferred_name(shared_info->inferred_name()); | 778 Handle<String> inferred_name(shared_info->inferred_name()); |
| 789 result->set_inferred_name(inferred_name); | 779 result->set_inferred_name(inferred_name); |
| 790 } | 780 } |
| 791 return result; | 781 return result; |
| 792 } | 782 } |
| 793 | 783 |
| 794 | 784 |
| 795 Handle<String> Parser::GetSymbol() { | 785 Handle<String> Parser::GetSymbol() { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 882 continue; | 872 continue; |
| 883 } | 873 } |
| 884 | 874 |
| 885 if (directive_prologue) { | 875 if (directive_prologue) { |
| 886 // A shot at a directive. | 876 // A shot at a directive. |
| 887 ExpressionStatement* e_stat; | 877 ExpressionStatement* e_stat; |
| 888 Literal* literal; | 878 Literal* literal; |
| 889 // Still processing directive prologue? | 879 // Still processing directive prologue? |
| 890 if ((e_stat = stat->AsExpressionStatement()) != NULL && | 880 if ((e_stat = stat->AsExpressionStatement()) != NULL && |
| 891 (literal = e_stat->expression()->AsLiteral()) != NULL && | 881 (literal = e_stat->expression()->AsLiteral()) != NULL && |
| 892 literal->handle()->IsString()) { | 882 literal->value()->IsString()) { |
| 893 Handle<String> directive = Handle<String>::cast(literal->handle()); | 883 Handle<String> directive = Handle<String>::cast(literal->value()); |
| 894 | 884 |
| 895 // Check "use strict" directive (ES5 14.1). | 885 // Check "use strict" directive (ES5 14.1). |
| 896 if (top_scope_->is_classic_mode() && | 886 if (top_scope_->is_classic_mode() && |
| 897 directive->Equals(isolate()->heap()->use_strict_string()) && | 887 directive->Equals(isolate()->heap()->use_strict_string()) && |
| 898 token_loc.end_pos - token_loc.beg_pos == | 888 token_loc.end_pos - token_loc.beg_pos == |
| 899 isolate()->heap()->use_strict_string()->length() + 2) { | 889 isolate()->heap()->use_strict_string()->length() + 2) { |
| 900 // TODO(mstarzinger): Global strict eval calls, need their own scope | 890 // TODO(mstarzinger): Global strict eval calls, need their own scope |
| 901 // as specified in ES5 10.4.2(3). The correct fix would be to always | 891 // as specified in ES5 10.4.2(3). The correct fix would be to always |
| 902 // add this scope in DoParseProgram(), but that requires adaptations | 892 // add this scope in DoParseProgram(), but that requires adaptations |
| 903 // all over the code base, so we go with a quick-fix for now. | 893 // all over the code base, so we go with a quick-fix for now. |
| (...skipping 2156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3060 ASSERT(prec >= 4); | 3050 ASSERT(prec >= 4); |
| 3061 Expression* x = ParseUnaryExpression(CHECK_OK); | 3051 Expression* x = ParseUnaryExpression(CHECK_OK); |
| 3062 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { | 3052 for (int prec1 = Precedence(peek(), accept_IN); prec1 >= prec; prec1--) { |
| 3063 // prec1 >= 4 | 3053 // prec1 >= 4 |
| 3064 while (Precedence(peek(), accept_IN) == prec1) { | 3054 while (Precedence(peek(), accept_IN) == prec1) { |
| 3065 Token::Value op = Next(); | 3055 Token::Value op = Next(); |
| 3066 int position = scanner().location().beg_pos; | 3056 int position = scanner().location().beg_pos; |
| 3067 Expression* y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); | 3057 Expression* y = ParseBinaryExpression(prec1 + 1, accept_IN, CHECK_OK); |
| 3068 | 3058 |
| 3069 // Compute some expressions involving only number literals. | 3059 // Compute some expressions involving only number literals. |
| 3070 if (x && x->AsLiteral() && x->AsLiteral()->handle()->IsNumber() && | 3060 if (x && x->AsLiteral() && x->AsLiteral()->value()->IsNumber() && |
| 3071 y && y->AsLiteral() && y->AsLiteral()->handle()->IsNumber()) { | 3061 y && y->AsLiteral() && y->AsLiteral()->value()->IsNumber()) { |
| 3072 double x_val = x->AsLiteral()->handle()->Number(); | 3062 double x_val = x->AsLiteral()->value()->Number(); |
| 3073 double y_val = y->AsLiteral()->handle()->Number(); | 3063 double y_val = y->AsLiteral()->value()->Number(); |
| 3074 | 3064 |
| 3075 switch (op) { | 3065 switch (op) { |
| 3076 case Token::ADD: | 3066 case Token::ADD: |
| 3077 x = factory()->NewNumberLiteral(x_val + y_val); | 3067 x = factory()->NewNumberLiteral(x_val + y_val); |
| 3078 continue; | 3068 continue; |
| 3079 case Token::SUB: | 3069 case Token::SUB: |
| 3080 x = factory()->NewNumberLiteral(x_val - y_val); | 3070 x = factory()->NewNumberLiteral(x_val - y_val); |
| 3081 continue; | 3071 continue; |
| 3082 case Token::MUL: | 3072 case Token::MUL: |
| 3083 x = factory()->NewNumberLiteral(x_val * y_val); | 3073 x = factory()->NewNumberLiteral(x_val * y_val); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3162 // '~' UnaryExpression | 3152 // '~' UnaryExpression |
| 3163 // '!' UnaryExpression | 3153 // '!' UnaryExpression |
| 3164 | 3154 |
| 3165 Token::Value op = peek(); | 3155 Token::Value op = peek(); |
| 3166 if (Token::IsUnaryOp(op)) { | 3156 if (Token::IsUnaryOp(op)) { |
| 3167 op = Next(); | 3157 op = Next(); |
| 3168 int position = scanner().location().beg_pos; | 3158 int position = scanner().location().beg_pos; |
| 3169 Expression* expression = ParseUnaryExpression(CHECK_OK); | 3159 Expression* expression = ParseUnaryExpression(CHECK_OK); |
| 3170 | 3160 |
| 3171 if (expression != NULL && (expression->AsLiteral() != NULL)) { | 3161 if (expression != NULL && (expression->AsLiteral() != NULL)) { |
| 3172 Handle<Object> literal = expression->AsLiteral()->handle(); | 3162 Handle<Object> literal = expression->AsLiteral()->value(); |
| 3173 if (op == Token::NOT) { | 3163 if (op == Token::NOT) { |
| 3174 // Convert the literal to a boolean condition and negate it. | 3164 // Convert the literal to a boolean condition and negate it. |
| 3175 bool condition = literal->BooleanValue(); | 3165 bool condition = literal->BooleanValue(); |
| 3176 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), | 3166 Handle<Object> result(isolate()->heap()->ToBoolean(!condition), |
| 3177 isolate()); | 3167 isolate()); |
| 3178 return factory()->NewLiteral(result); | 3168 return factory()->NewLiteral(result); |
| 3179 } else if (literal->IsNumber()) { | 3169 } else if (literal->IsNumber()) { |
| 3180 // Compute some expressions involving only number literals. | 3170 // Compute some expressions involving only number literals. |
| 3181 double value = literal->Number(); | 3171 double value = literal->Number(); |
| 3182 switch (op) { | 3172 switch (op) { |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3727 } | 3717 } |
| 3728 | 3718 |
| 3729 | 3719 |
| 3730 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { | 3720 bool CompileTimeValue::IsCompileTimeValue(Expression* expression) { |
| 3731 if (expression->AsLiteral() != NULL) return true; | 3721 if (expression->AsLiteral() != NULL) return true; |
| 3732 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); | 3722 MaterializedLiteral* lit = expression->AsMaterializedLiteral(); |
| 3733 return lit != NULL && lit->is_simple(); | 3723 return lit != NULL && lit->is_simple(); |
| 3734 } | 3724 } |
| 3735 | 3725 |
| 3736 | 3726 |
| 3737 bool CompileTimeValue::ArrayLiteralElementNeedsInitialization( | |
| 3738 Expression* value) { | |
| 3739 // If value is a literal the property value is already set in the | |
| 3740 // boilerplate object. | |
| 3741 if (value->AsLiteral() != NULL) return false; | |
| 3742 // If value is a materialized literal the property value is already set | |
| 3743 // in the boilerplate object if it is simple. | |
| 3744 if (CompileTimeValue::IsCompileTimeValue(value)) return false; | |
| 3745 return true; | |
| 3746 } | |
| 3747 | |
| 3748 | |
| 3749 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { | 3727 Handle<FixedArray> CompileTimeValue::GetValue(Expression* expression) { |
| 3750 Factory* factory = Isolate::Current()->factory(); | 3728 Factory* factory = Isolate::Current()->factory(); |
| 3751 ASSERT(IsCompileTimeValue(expression)); | 3729 ASSERT(IsCompileTimeValue(expression)); |
| 3752 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); | 3730 Handle<FixedArray> result = factory->NewFixedArray(2, TENURED); |
| 3753 ObjectLiteral* object_literal = expression->AsObjectLiteral(); | 3731 ObjectLiteral* object_literal = expression->AsObjectLiteral(); |
| 3754 if (object_literal != NULL) { | 3732 if (object_literal != NULL) { |
| 3755 ASSERT(object_literal->is_simple()); | 3733 ASSERT(object_literal->is_simple()); |
| 3756 if (object_literal->fast_elements()) { | 3734 if (object_literal->fast_elements()) { |
| 3757 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); | 3735 result->set(kLiteralTypeSlot, Smi::FromInt(OBJECT_LITERAL_FAST_ELEMENTS)); |
| 3758 } else { | 3736 } else { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3776 } | 3754 } |
| 3777 | 3755 |
| 3778 | 3756 |
| 3779 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { | 3757 Handle<FixedArray> CompileTimeValue::GetElements(Handle<FixedArray> value) { |
| 3780 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); | 3758 return Handle<FixedArray>(FixedArray::cast(value->get(kElementsSlot))); |
| 3781 } | 3759 } |
| 3782 | 3760 |
| 3783 | 3761 |
| 3784 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { | 3762 Handle<Object> Parser::GetBoilerplateValue(Expression* expression) { |
| 3785 if (expression->AsLiteral() != NULL) { | 3763 if (expression->AsLiteral() != NULL) { |
| 3786 return expression->AsLiteral()->handle(); | 3764 return expression->AsLiteral()->value(); |
| 3787 } | 3765 } |
| 3788 if (CompileTimeValue::IsCompileTimeValue(expression)) { | 3766 if (CompileTimeValue::IsCompileTimeValue(expression)) { |
| 3789 return CompileTimeValue::GetValue(expression); | 3767 return CompileTimeValue::GetValue(expression); |
| 3790 } | 3768 } |
| 3791 return isolate()->factory()->uninitialized_value(); | 3769 return isolate()->factory()->uninitialized_value(); |
| 3792 } | 3770 } |
| 3793 | 3771 |
| 3794 // Validation per 11.1.5 Object Initialiser | 3772 // Validation per 11.1.5 Object Initialiser |
| 3795 class ObjectLiteralPropertyChecker { | 3773 class ObjectLiteralPropertyChecker { |
| 3796 public: | 3774 public: |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3889 continue; | 3867 continue; |
| 3890 } | 3868 } |
| 3891 MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); | 3869 MaterializedLiteral* m_literal = property->value()->AsMaterializedLiteral(); |
| 3892 if (m_literal != NULL && m_literal->depth() >= depth_acc) { | 3870 if (m_literal != NULL && m_literal->depth() >= depth_acc) { |
| 3893 depth_acc = m_literal->depth() + 1; | 3871 depth_acc = m_literal->depth() + 1; |
| 3894 } | 3872 } |
| 3895 | 3873 |
| 3896 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined | 3874 // Add CONSTANT and COMPUTED properties to boilerplate. Use undefined |
| 3897 // value for COMPUTED properties, the real value is filled in at | 3875 // value for COMPUTED properties, the real value is filled in at |
| 3898 // runtime. The enumeration order is maintained. | 3876 // runtime. The enumeration order is maintained. |
| 3899 Handle<Object> key = property->key()->handle(); | 3877 Handle<Object> key = property->key()->value(); |
| 3900 Handle<Object> value = GetBoilerplateValue(property->value()); | 3878 Handle<Object> value = GetBoilerplateValue(property->value()); |
| 3901 | 3879 |
| 3902 // Ensure objects that may, at any point in time, contain fields with double | 3880 // Ensure objects that may, at any point in time, contain fields with double |
| 3903 // representation are always treated as nested objects. This is true for | 3881 // representation are always treated as nested objects. This is true for |
| 3904 // computed fields (value is undefined), and smi and double literals | 3882 // computed fields (value is undefined), and smi and double literals |
| 3905 // (value->IsNumber()). | 3883 // (value->IsNumber()). |
| 3906 // TODO(verwaest): Remove once we can store them inline. | 3884 // TODO(verwaest): Remove once we can store them inline. |
| 3907 if (FLAG_track_double_fields && | 3885 if (FLAG_track_double_fields && |
| 3908 (value->IsNumber() || value->IsUninitialized())) { | 3886 (value->IsNumber() || value->IsUninitialized())) { |
| 3909 *may_store_doubles = true; | 3887 *may_store_doubles = true; |
| (...skipping 2027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5937 ASSERT(info()->isolate()->has_pending_exception()); | 5915 ASSERT(info()->isolate()->has_pending_exception()); |
| 5938 } else { | 5916 } else { |
| 5939 result = ParseProgram(); | 5917 result = ParseProgram(); |
| 5940 } | 5918 } |
| 5941 } | 5919 } |
| 5942 info()->SetFunction(result); | 5920 info()->SetFunction(result); |
| 5943 return (result != NULL); | 5921 return (result != NULL); |
| 5944 } | 5922 } |
| 5945 | 5923 |
| 5946 } } // namespace v8::internal | 5924 } } // namespace v8::internal |
| OLD | NEW |