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 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3; | 699 (unibrow::Utf8::kMaxThreeByteChar - unibrow::Utf8::kMaxTwoByteChar) * 3; |
700 static const unsigned kAllUtf8CharsSizeU = | 700 static const unsigned kAllUtf8CharsSizeU = |
701 static_cast<unsigned>(kAllUtf8CharsSize); | 701 static_cast<unsigned>(kAllUtf8CharsSize); |
702 | 702 |
703 char buffer[kAllUtf8CharsSizeU]; | 703 char buffer[kAllUtf8CharsSizeU]; |
704 unsigned cursor = 0; | 704 unsigned cursor = 0; |
705 for (int i = 0; i <= kMaxUC16Char; i++) { | 705 for (int i = 0; i <= kMaxUC16Char; i++) { |
706 cursor += unibrow::Utf8::Encode(buffer + cursor, i, | 706 cursor += unibrow::Utf8::Encode(buffer + cursor, i, |
707 unibrow::Utf16::kNoPreviousCharacter, true); | 707 unibrow::Utf16::kNoPreviousCharacter, true); |
708 } | 708 } |
709 DCHECK(cursor == kAllUtf8CharsSizeU); | 709 CHECK(cursor == kAllUtf8CharsSizeU); |
710 | 710 |
711 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), | 711 i::Utf8ToUtf16CharacterStream stream(reinterpret_cast<const i::byte*>(buffer), |
712 kAllUtf8CharsSizeU); | 712 kAllUtf8CharsSizeU); |
713 int32_t bad = unibrow::Utf8::kBadChar; | 713 int32_t bad = unibrow::Utf8::kBadChar; |
714 for (int i = 0; i <= kMaxUC16Char; i++) { | 714 for (int i = 0; i <= kMaxUC16Char; i++) { |
715 CHECK_EQU(i, stream.pos()); | 715 CHECK_EQU(i, stream.pos()); |
716 int32_t c = stream.Advance(); | 716 int32_t c = stream.Advance(); |
717 if (i >= 0xd800 && i <= 0xdfff) { | 717 if (i >= 0xd800 && i <= 0xdfff) { |
718 CHECK_EQ(bad, c); | 718 CHECK_EQ(bad, c); |
719 } else { | 719 } else { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 i::Token::CASE, | 795 i::Token::CASE, |
796 i::Token::DEFAULT, | 796 i::Token::DEFAULT, |
797 i::Token::CONST, | 797 i::Token::CONST, |
798 i::Token::LBRACE, | 798 i::Token::LBRACE, |
799 // Skipped part here | 799 // Skipped part here |
800 i::Token::RBRACE, | 800 i::Token::RBRACE, |
801 i::Token::DO, | 801 i::Token::DO, |
802 i::Token::EOS, | 802 i::Token::EOS, |
803 i::Token::ILLEGAL | 803 i::Token::ILLEGAL |
804 }; | 804 }; |
805 DCHECK_EQ('{', str2[19]); | 805 CHECK_EQ('{', str2[19]); |
806 DCHECK_EQ('}', str2[37]); | 806 CHECK_EQ('}', str2[37]); |
807 TestStreamScanner(&stream2, expectations2, 20, 37); | 807 TestStreamScanner(&stream2, expectations2, 20, 37); |
808 | 808 |
809 const char* str3 = "{}}}}"; | 809 const char* str3 = "{}}}}"; |
810 i::Token::Value expectations3[] = { | 810 i::Token::Value expectations3[] = { |
811 i::Token::LBRACE, | 811 i::Token::LBRACE, |
812 i::Token::RBRACE, | 812 i::Token::RBRACE, |
813 i::Token::RBRACE, | 813 i::Token::RBRACE, |
814 i::Token::RBRACE, | 814 i::Token::RBRACE, |
815 i::Token::RBRACE, | 815 i::Token::RBRACE, |
816 i::Token::EOS, | 816 i::Token::EOS, |
(...skipping 2521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3338 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 3338 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); |
3339 avf.Internalize(isolate); | 3339 avf.Internalize(isolate); |
3340 const i::AstRawString* name = avf.GetOneByteString("result"); | 3340 const i::AstRawString* name = avf.GetOneByteString("result"); |
3341 i::Handle<i::String> str = name->string(); | 3341 i::Handle<i::String> str = name->string(); |
3342 CHECK(str->IsInternalizedString()); | 3342 CHECK(str->IsInternalizedString()); |
3343 i::Scope* script_scope = | 3343 i::Scope* script_scope = |
3344 new (&zone) i::Scope(&zone, NULL, i::SCRIPT_SCOPE, &avf); | 3344 new (&zone) i::Scope(&zone, NULL, i::SCRIPT_SCOPE, &avf); |
3345 script_scope->Initialize(); | 3345 script_scope->Initialize(); |
3346 i::Scope* s = | 3346 i::Scope* s = |
3347 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope); | 3347 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope); |
3348 DCHECK(s != script_scope); | 3348 CHECK(s != script_scope); |
3349 DCHECK(name != NULL); | 3349 CHECK(name != NULL); |
3350 | 3350 |
3351 // Get result from h's function context (that is f's context) | 3351 // Get result from h's function context (that is f's context) |
3352 i::Variable* var = s->Lookup(name); | 3352 i::Variable* var = s->Lookup(name); |
3353 | 3353 |
3354 CHECK(var != NULL); | 3354 CHECK(var != NULL); |
3355 // Maybe assigned should survive deserialization | 3355 // Maybe assigned should survive deserialization |
3356 CHECK(var->maybe_assigned() == i::kMaybeAssigned); | 3356 CHECK(var->maybe_assigned() == i::kMaybeAssigned); |
3357 // TODO(sigurds) Figure out if is_used should survive context serialization. | 3357 // TODO(sigurds) Figure out if is_used should survive context serialization. |
3358 } | 3358 } |
3359 | 3359 |
(...skipping 26 matching lines...) Expand all Loading... |
3386 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); | 3386 i::Handle<i::JSFunction> f = i::Handle<i::JSFunction>::cast(o); |
3387 i::Context* context = f->context(); | 3387 i::Context* context = f->context(); |
3388 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); | 3388 i::AstValueFactory avf(&zone, isolate->heap()->HashSeed()); |
3389 avf.Internalize(isolate); | 3389 avf.Internalize(isolate); |
3390 | 3390 |
3391 i::Scope* script_scope = | 3391 i::Scope* script_scope = |
3392 new (&zone) i::Scope(&zone, NULL, i::SCRIPT_SCOPE, &avf); | 3392 new (&zone) i::Scope(&zone, NULL, i::SCRIPT_SCOPE, &avf); |
3393 script_scope->Initialize(); | 3393 script_scope->Initialize(); |
3394 i::Scope* s = | 3394 i::Scope* s = |
3395 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope); | 3395 i::Scope::DeserializeScopeChain(isolate, &zone, context, script_scope); |
3396 DCHECK(s != script_scope); | 3396 CHECK(s != script_scope); |
3397 const i::AstRawString* name_x = avf.GetOneByteString("x"); | 3397 const i::AstRawString* name_x = avf.GetOneByteString("x"); |
3398 | 3398 |
3399 // Get result from f's function context (that is g's outer context) | 3399 // Get result from f's function context (that is g's outer context) |
3400 i::Variable* var_x = s->Lookup(name_x); | 3400 i::Variable* var_x = s->Lookup(name_x); |
3401 CHECK(var_x != NULL); | 3401 CHECK(var_x != NULL); |
3402 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); | 3402 CHECK(var_x->maybe_assigned() == i::kMaybeAssigned); |
3403 } | 3403 } |
3404 | 3404 |
3405 | 3405 |
3406 TEST(InnerAssignment) { | 3406 TEST(InnerAssignment) { |
(...skipping 4344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7751 "var publ\\u0069c = 1;", | 7751 "var publ\\u0069c = 1;", |
7752 "var { publ\\u0069c } = {};", | 7752 "var { publ\\u0069c } = {};", |
7753 NULL}; | 7753 NULL}; |
7754 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, | 7754 RunParserSyncTest(sloppy_context_data, valid_data, kSuccess, NULL, 0, |
7755 always_flags, arraysize(always_flags)); | 7755 always_flags, arraysize(always_flags)); |
7756 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7756 RunParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7757 always_flags, arraysize(always_flags)); | 7757 always_flags, arraysize(always_flags)); |
7758 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, | 7758 RunModuleParserSyncTest(strict_context_data, valid_data, kError, NULL, 0, |
7759 always_flags, arraysize(always_flags)); | 7759 always_flags, arraysize(always_flags)); |
7760 } | 7760 } |
OLD | NEW |