OLD | NEW |
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/bailout-reason.h" | 9 #include "src/bailout-reason.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2918 Variable* iterator = scope_->DeclarationScope()->NewTemporary( | 2918 Variable* iterator = scope_->DeclarationScope()->NewTemporary( |
2919 ast_value_factory()->dot_iterator_string()); | 2919 ast_value_factory()->dot_iterator_string()); |
2920 Variable* result = scope_->DeclarationScope()->NewTemporary( | 2920 Variable* result = scope_->DeclarationScope()->NewTemporary( |
2921 ast_value_factory()->dot_result_string()); | 2921 ast_value_factory()->dot_result_string()); |
2922 | 2922 |
2923 Expression* assign_iterator; | 2923 Expression* assign_iterator; |
2924 Expression* next_result; | 2924 Expression* next_result; |
2925 Expression* result_done; | 2925 Expression* result_done; |
2926 Expression* assign_each; | 2926 Expression* assign_each; |
2927 | 2927 |
2928 // var iterator = subject[Symbol.iterator](); | 2928 // iterator = subject[Symbol.iterator](); |
2929 assign_iterator = factory()->NewAssignment( | 2929 assign_iterator = factory()->NewAssignment( |
2930 Token::ASSIGN, factory()->NewVariableProxy(iterator), | 2930 Token::ASSIGN, factory()->NewVariableProxy(iterator), |
2931 GetIterator(subject, factory()), subject->position()); | 2931 GetIterator(subject, factory()), subject->position()); |
2932 | 2932 |
2933 // var result = iterator.next(); | 2933 // !%_IsSpecObject(result = iterator.next()) && |
| 2934 // %ThrowIteratorResultNotAnObject(result) |
2934 { | 2935 { |
| 2936 // result = iterator.next() |
2935 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); | 2937 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); |
2936 Expression* next_literal = factory()->NewStringLiteral( | 2938 Expression* next_literal = factory()->NewStringLiteral( |
2937 ast_value_factory()->next_string(), RelocInfo::kNoPosition); | 2939 ast_value_factory()->next_string(), RelocInfo::kNoPosition); |
2938 Expression* next_property = factory()->NewProperty( | 2940 Expression* next_property = factory()->NewProperty( |
2939 iterator_proxy, next_literal, RelocInfo::kNoPosition); | 2941 iterator_proxy, next_literal, RelocInfo::kNoPosition); |
2940 ZoneList<Expression*>* next_arguments = | 2942 ZoneList<Expression*>* next_arguments = |
2941 new(zone()) ZoneList<Expression*>(0, zone()); | 2943 new (zone()) ZoneList<Expression*>(0, zone()); |
2942 Expression* next_call = factory()->NewCall(next_property, next_arguments, | 2944 Expression* next_call = factory()->NewCall(next_property, next_arguments, |
2943 subject->position()); | 2945 subject->position()); |
2944 Expression* result_proxy = factory()->NewVariableProxy(result); | 2946 Expression* result_proxy = factory()->NewVariableProxy(result); |
2945 next_result = factory()->NewAssignment(Token::ASSIGN, result_proxy, | 2947 next_result = factory()->NewAssignment(Token::ASSIGN, result_proxy, |
2946 next_call, subject->position()); | 2948 next_call, subject->position()); |
| 2949 |
| 2950 // %_IsSpecObject(...) |
| 2951 ZoneList<Expression*>* is_spec_object_args = |
| 2952 new (zone()) ZoneList<Expression*>(1, zone()); |
| 2953 is_spec_object_args->Add(next_result, zone()); |
| 2954 Expression* is_spec_object_call = factory()->NewCallRuntime( |
| 2955 NULL, Runtime::FunctionForId(Runtime::kInlineIsSpecObject), |
| 2956 is_spec_object_args, subject->position()); |
| 2957 |
| 2958 // %ThrowIteratorResultNotAnObject(result) |
| 2959 Expression* result_proxy_again = factory()->NewVariableProxy(result); |
| 2960 ZoneList<Expression*>* throw_arguments = |
| 2961 new (zone()) ZoneList<Expression*>(1, zone()); |
| 2962 throw_arguments->Add(result_proxy_again, zone()); |
| 2963 Expression* throw_call = factory()->NewCallRuntime( |
| 2964 NULL, |
| 2965 Runtime::FunctionForId(Runtime::kThrowIteratorResultNotAnObject), |
| 2966 throw_arguments, subject->position()); |
| 2967 |
| 2968 next_result = factory()->NewBinaryOperation( |
| 2969 Token::AND, factory()->NewUnaryOperation( |
| 2970 Token::NOT, is_spec_object_call, subject->position()), |
| 2971 throw_call, subject->position()); |
2947 } | 2972 } |
2948 | 2973 |
2949 // result.done | 2974 // result.done |
2950 { | 2975 { |
2951 Expression* done_literal = factory()->NewStringLiteral( | 2976 Expression* done_literal = factory()->NewStringLiteral( |
2952 ast_value_factory()->done_string(), RelocInfo::kNoPosition); | 2977 ast_value_factory()->done_string(), RelocInfo::kNoPosition); |
2953 Expression* result_proxy = factory()->NewVariableProxy(result); | 2978 Expression* result_proxy = factory()->NewVariableProxy(result); |
2954 result_done = factory()->NewProperty( | 2979 result_done = factory()->NewProperty( |
2955 result_proxy, done_literal, RelocInfo::kNoPosition); | 2980 result_proxy, done_literal, RelocInfo::kNoPosition); |
2956 } | 2981 } |
(...skipping 2506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5463 } else { | 5488 } else { |
5464 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5489 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5465 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5490 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5466 raw_string->length()); | 5491 raw_string->length()); |
5467 } | 5492 } |
5468 } | 5493 } |
5469 | 5494 |
5470 return running_hash; | 5495 return running_hash; |
5471 } | 5496 } |
5472 } } // namespace v8::internal | 5497 } } // namespace v8::internal |
OLD | NEW |