| 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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 static const unsigned kAllUtf8CharsSizeU = | 665 static const unsigned kAllUtf8CharsSizeU = |
| 666 static_cast<unsigned>(kAllUtf8CharsSize); | 666 static_cast<unsigned>(kAllUtf8CharsSize); |
| 667 | 667 |
| 668 char buffer[kAllUtf8CharsSizeU]; | 668 char buffer[kAllUtf8CharsSizeU]; |
| 669 unsigned cursor = 0; | 669 unsigned cursor = 0; |
| 670 for (int i = 0; i <= kMaxUC16Char; i++) { | 670 for (int i = 0; i <= kMaxUC16Char; i++) { |
| 671 cursor += unibrow::Utf8::Encode(buffer + cursor, | 671 cursor += unibrow::Utf8::Encode(buffer + cursor, |
| 672 i, | 672 i, |
| 673 unibrow::Utf16::kNoPreviousCharacter); | 673 unibrow::Utf16::kNoPreviousCharacter); |
| 674 } | 674 } |
| 675 ASSERT(cursor == kAllUtf8CharsSizeU); | 675 DCHECK(cursor == kAllUtf8CharsSizeU); |
| 676 | 676 |
| 677 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), | 677 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), |
| 678 kAllUtf8CharsSizeU); | 678 kAllUtf8CharsSizeU); |
| 679 for (int i = 0; i <= kMaxUC16Char; i++) { | 679 for (int i = 0; i <= kMaxUC16Char; i++) { |
| 680 CHECK_EQU(i, stream.pos()); | 680 CHECK_EQU(i, stream.pos()); |
| 681 int32_t c = stream.Advance(); | 681 int32_t c = stream.Advance(); |
| 682 CHECK_EQ(i, c); | 682 CHECK_EQ(i, c); |
| 683 CHECK_EQU(i + 1, stream.pos()); | 683 CHECK_EQU(i + 1, stream.pos()); |
| 684 } | 684 } |
| 685 for (int i = kMaxUC16Char; i >= 0; i--) { | 685 for (int i = kMaxUC16Char; i >= 0; i--) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 754 i::Token::CASE, | 754 i::Token::CASE, |
| 755 i::Token::DEFAULT, | 755 i::Token::DEFAULT, |
| 756 i::Token::CONST, | 756 i::Token::CONST, |
| 757 i::Token::LBRACE, | 757 i::Token::LBRACE, |
| 758 // Skipped part here | 758 // Skipped part here |
| 759 i::Token::RBRACE, | 759 i::Token::RBRACE, |
| 760 i::Token::DO, | 760 i::Token::DO, |
| 761 i::Token::EOS, | 761 i::Token::EOS, |
| 762 i::Token::ILLEGAL | 762 i::Token::ILLEGAL |
| 763 }; | 763 }; |
| 764 ASSERT_EQ('{', str2[19]); | 764 DCHECK_EQ('{', str2[19]); |
| 765 ASSERT_EQ('}', str2[37]); | 765 DCHECK_EQ('}', str2[37]); |
| 766 TestStreamScanner(&stream2, expectations2, 20, 37); | 766 TestStreamScanner(&stream2, expectations2, 20, 37); |
| 767 | 767 |
| 768 const char* str3 = "{}}}}"; | 768 const char* str3 = "{}}}}"; |
| 769 i::Token::Value expectations3[] = { | 769 i::Token::Value expectations3[] = { |
| 770 i::Token::LBRACE, | 770 i::Token::LBRACE, |
| 771 i::Token::RBRACE, | 771 i::Token::RBRACE, |
| 772 i::Token::RBRACE, | 772 i::Token::RBRACE, |
| 773 i::Token::RBRACE, | 773 i::Token::RBRACE, |
| 774 i::Token::RBRACE, | 774 i::Token::RBRACE, |
| 775 i::Token::EOS, | 775 i::Token::EOS, |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2887 i::Context* context = f->context(); | 2887 i::Context* context = f->context(); |
| 2888 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 2888 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); |
| 2889 avf.Internalize(isolate); | 2889 avf.Internalize(isolate); |
| 2890 const i::AstRawString* name = avf.GetOneByteString("result"); | 2890 const i::AstRawString* name = avf.GetOneByteString("result"); |
| 2891 i::Handle<i::String> str = name->string(); | 2891 i::Handle<i::String> str = name->string(); |
| 2892 CHECK(str->IsInternalizedString()); | 2892 CHECK(str->IsInternalizedString()); |
| 2893 i::Scope* global_scope = | 2893 i::Scope* global_scope = |
| 2894 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); | 2894 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); |
| 2895 global_scope->Initialize(); | 2895 global_scope->Initialize(); |
| 2896 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); | 2896 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); |
| 2897 ASSERT(s != global_scope); | 2897 DCHECK(s != global_scope); |
| 2898 ASSERT(name != NULL); | 2898 DCHECK(name != NULL); |
| 2899 | 2899 |
| 2900 // Get result from h's function context (that is f's context) | 2900 // Get result from h's function context (that is f's context) |
| 2901 i::Variable* var = s->Lookup(name); | 2901 i::Variable* var = s->Lookup(name); |
| 2902 | 2902 |
| 2903 CHECK(var != NULL); | 2903 CHECK(var != NULL); |
| 2904 // Maybe assigned should survive deserialization | 2904 // Maybe assigned should survive deserialization |
| 2905 CHECK(var->maybe_assigned() == i::kMaybeAssigned); | 2905 CHECK(var->maybe_assigned() == i::kMaybeAssigned); |
| 2906 // TODO(sigurds) Figure out if is_used should survive context serialization. | 2906 // TODO(sigurds) Figure out if is_used should survive context serialization. |
| 2907 } | 2907 } |
| 2908 | 2908 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 2934 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); | 2934 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); |
| 2935 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); | 2935 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); |
| 2936 i::Context* context = f->context(); | 2936 i::Context* context = f->context(); |
| 2937 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 2937 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); |
| 2938 avf.Internalize(isolate); | 2938 avf.Internalize(isolate); |
| 2939 | 2939 |
| 2940 i::Scope* global_scope = | 2940 i::Scope* global_scope = |
| 2941 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); | 2941 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); |
| 2942 global_scope->Initialize(); | 2942 global_scope->Initialize(); |
| 2943 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); | 2943 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); |
| 2944 ASSERT(s != global_scope); | 2944 DCHECK(s != global_scope); |
| 2945 const i::AstRawString* name_x = avf.GetOneByteString("x"); | 2945 const i::AstRawString* name_x = avf.GetOneByteString("x"); |
| 2946 | 2946 |
| 2947 // Get result from f's function context (that is g's outer context) | 2947 // Get result from f's function context (that is g's outer context) |
| 2948 i::Variable* var_x = s->Lookup(name_x); | 2948 i::Variable* var_x = s->Lookup(name_x); |
| 2949 CHECK(var_x != NULL); | 2949 CHECK(var_x != NULL); |
| 2950 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); | 2950 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); |
| 2951 } | 2951 } |
| 2952 | 2952 |
| 2953 | 2953 |
| 2954 TEST(ExportsMaybeAssigned) { | 2954 TEST(ExportsMaybeAssigned) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2981 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); | 2981 i::Handle<i::Object> o = v8::Utils::OpenHandle(*v); |
| 2982 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); | 2982 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); |
| 2983 i::Context* context = f->context(); | 2983 i::Context* context = f->context(); |
| 2984 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 2984 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); |
| 2985 avf.Internalize(isolate); | 2985 avf.Internalize(isolate); |
| 2986 | 2986 |
| 2987 i::Scope* global_scope = | 2987 i::Scope* global_scope = |
| 2988 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); | 2988 new (&zone) i::Scope(NULL, i::GLOBAL_SCOPE, &avf, &zone); |
| 2989 global_scope->Initialize(); | 2989 global_scope->Initialize(); |
| 2990 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); | 2990 i::Scope* s = i::Scope::DeserializeScopeChain(context, global_scope, &zone); |
| 2991 ASSERT(s != global_scope); | 2991 DCHECK(s != global_scope); |
| 2992 const i::AstRawString* name_x = avf.GetOneByteString("x"); | 2992 const i::AstRawString* name_x = avf.GetOneByteString("x"); |
| 2993 const i::AstRawString* name_f = avf.GetOneByteString("f"); | 2993 const i::AstRawString* name_f = avf.GetOneByteString("f"); |
| 2994 const i::AstRawString* name_y = avf.GetOneByteString("y"); | 2994 const i::AstRawString* name_y = avf.GetOneByteString("y"); |
| 2995 const i::AstRawString* name_B = avf.GetOneByteString("B"); | 2995 const i::AstRawString* name_B = avf.GetOneByteString("B"); |
| 2996 const i::AstRawString* name_C = avf.GetOneByteString("C"); | 2996 const i::AstRawString* name_C = avf.GetOneByteString("C"); |
| 2997 | 2997 |
| 2998 // Get result from h's function context (that is f's context) | 2998 // Get result from h's function context (that is f's context) |
| 2999 i::Variable* var_x = s->Lookup(name_x); | 2999 i::Variable* var_x = s->Lookup(name_x); |
| 3000 CHECK(var_x != NULL); | 3000 CHECK(var_x != NULL); |
| 3001 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); | 3001 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3340 | 3340 |
| 3341 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) | 3341 // Arrow has more precedence, this is the same as: foo ? bar : (baz = {}) |
| 3342 "foo ? bar : baz => {}", | 3342 "foo ? bar : baz => {}", |
| 3343 NULL | 3343 NULL |
| 3344 }; | 3344 }; |
| 3345 | 3345 |
| 3346 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; | 3346 static const ParserFlag always_flags[] = {kAllowArrowFunctions}; |
| 3347 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, | 3347 RunParserSyncTest(context_data, statement_data, kSuccess, NULL, 0, |
| 3348 always_flags, ARRAY_SIZE(always_flags)); | 3348 always_flags, ARRAY_SIZE(always_flags)); |
| 3349 } | 3349 } |
| OLD | NEW |