| OLD | NEW |
| 1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2010 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 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 ->NewStringFromUtf8(CStrVector(source)) | 690 ->NewStringFromUtf8(CStrVector(source)) |
| 691 .ToHandleChecked(); | 691 .ToHandleChecked(); |
| 692 Handle<String> copy_source = isolate->factory() | 692 Handle<String> copy_source = isolate->factory() |
| 693 ->NewStringFromUtf8(CStrVector(source)) | 693 ->NewStringFromUtf8(CStrVector(source)) |
| 694 .ToHandleChecked(); | 694 .ToHandleChecked(); |
| 695 CHECK(!orig_source.is_identical_to(copy_source)); | 695 CHECK(!orig_source.is_identical_to(copy_source)); |
| 696 CHECK(orig_source->Equals(*copy_source)); | 696 CHECK(orig_source->Equals(*copy_source)); |
| 697 | 697 |
| 698 ScriptData* cache = NULL; | 698 ScriptData* cache = NULL; |
| 699 | 699 |
| 700 Handle<SharedFunctionInfo> orig = | 700 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( |
| 701 Compiler::CompileScript(orig_source, Handle<String>(), 0, 0, false, | 701 orig_source, Handle<String>(), 0, 0, false, |
| 702 Handle<Context>(isolate->native_context()), NULL, | 702 Handle<Context>(isolate->native_context()), NULL, &cache, |
| 703 &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE); | 703 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); |
| 704 | 704 |
| 705 int builtins_count = CountBuiltins(); | 705 int builtins_count = CountBuiltins(); |
| 706 | 706 |
| 707 Handle<SharedFunctionInfo> copy; | 707 Handle<SharedFunctionInfo> copy; |
| 708 { | 708 { |
| 709 DisallowCompilation no_compile_expected(isolate); | 709 DisallowCompilation no_compile_expected(isolate); |
| 710 copy = Compiler::CompileScript(copy_source, Handle<String>(), 0, 0, false, | 710 copy = Compiler::CompileScript( |
| 711 Handle<Context>(isolate->native_context()), | 711 copy_source, Handle<String>(), 0, 0, false, |
| 712 NULL, &cache, CONSUME_CACHED_DATA, | 712 Handle<Context>(isolate->native_context()), NULL, &cache, |
| 713 NOT_NATIVES_CODE); | 713 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); |
| 714 } | 714 } |
| 715 |
| 715 CHECK_NE(*orig, *copy); | 716 CHECK_NE(*orig, *copy); |
| 716 CHECK(Script::cast(copy->script())->source() == *copy_source); | 717 CHECK(Script::cast(copy->script())->source() == *copy_source); |
| 717 | 718 |
| 718 Handle<JSFunction> copy_fun = | 719 Handle<JSFunction> copy_fun = |
| 719 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 720 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 720 copy, isolate->native_context()); | 721 copy, isolate->native_context()); |
| 721 Handle<JSObject> global(isolate->context()->global_object()); | 722 Handle<JSObject> global(isolate->context()->global_object()); |
| 722 Handle<Object> copy_result = | 723 Handle<Object> copy_result = |
| 723 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 724 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
| 724 CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value()); | 725 CHECK_EQ(2, Handle<Smi>::cast(copy_result)->value()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 744 .ToHandleChecked(); | 745 .ToHandleChecked(); |
| 745 Handle<String> copy_source = isolate->factory() | 746 Handle<String> copy_source = isolate->factory() |
| 746 ->NewStringFromUtf8(CStrVector(source)) | 747 ->NewStringFromUtf8(CStrVector(source)) |
| 747 .ToHandleChecked(); | 748 .ToHandleChecked(); |
| 748 CHECK(!orig_source.is_identical_to(copy_source)); | 749 CHECK(!orig_source.is_identical_to(copy_source)); |
| 749 CHECK(orig_source->Equals(*copy_source)); | 750 CHECK(orig_source->Equals(*copy_source)); |
| 750 | 751 |
| 751 Handle<JSObject> global(isolate->context()->global_object()); | 752 Handle<JSObject> global(isolate->context()->global_object()); |
| 752 ScriptData* cache = NULL; | 753 ScriptData* cache = NULL; |
| 753 | 754 |
| 754 Handle<SharedFunctionInfo> orig = | 755 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( |
| 755 Compiler::CompileScript(orig_source, Handle<String>(), 0, 0, false, | 756 orig_source, Handle<String>(), 0, 0, false, |
| 756 Handle<Context>(isolate->native_context()), NULL, | 757 Handle<Context>(isolate->native_context()), NULL, &cache, |
| 757 &cache, PRODUCE_CACHED_DATA, NOT_NATIVES_CODE); | 758 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); |
| 758 Handle<JSFunction> orig_fun = | 759 Handle<JSFunction> orig_fun = |
| 759 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 760 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 760 orig, isolate->native_context()); | 761 orig, isolate->native_context()); |
| 761 Handle<Object> orig_result = | 762 Handle<Object> orig_result = |
| 762 Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked(); | 763 Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked(); |
| 763 CHECK(orig_result->IsInternalizedString()); | 764 CHECK(orig_result->IsInternalizedString()); |
| 764 | 765 |
| 765 int builtins_count = CountBuiltins(); | 766 int builtins_count = CountBuiltins(); |
| 766 | 767 |
| 767 Handle<SharedFunctionInfo> copy; | 768 Handle<SharedFunctionInfo> copy; |
| 768 { | 769 { |
| 769 DisallowCompilation no_compile_expected(isolate); | 770 DisallowCompilation no_compile_expected(isolate); |
| 770 copy = Compiler::CompileScript(copy_source, Handle<String>(), 0, 0, false, | 771 copy = Compiler::CompileScript( |
| 771 Handle<Context>(isolate->native_context()), | 772 copy_source, Handle<String>(), 0, 0, false, |
| 772 NULL, &cache, CONSUME_CACHED_DATA, | 773 Handle<Context>(isolate->native_context()), NULL, &cache, |
| 773 NOT_NATIVES_CODE); | 774 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); |
| 774 } | 775 } |
| 775 CHECK_NE(*orig, *copy); | 776 CHECK_NE(*orig, *copy); |
| 776 CHECK(Script::cast(copy->script())->source() == *copy_source); | 777 CHECK(Script::cast(copy->script())->source() == *copy_source); |
| 777 | 778 |
| 778 Handle<JSFunction> copy_fun = | 779 Handle<JSFunction> copy_fun = |
| 779 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 780 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
| 780 copy, isolate->native_context()); | 781 copy, isolate->native_context()); |
| 781 CHECK_NE(*orig_fun, *copy_fun); | 782 CHECK_NE(*orig_fun, *copy_fun); |
| 782 Handle<Object> copy_result = | 783 Handle<Object> copy_result = |
| 783 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 784 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
| 784 CHECK(orig_result.is_identical_to(copy_result)); | 785 CHECK(orig_result.is_identical_to(copy_result)); |
| 785 Handle<String> expected = | 786 Handle<String> expected = |
| 786 isolate->factory()->NewStringFromAsciiChecked("string1"); | 787 isolate->factory()->NewStringFromAsciiChecked("string1"); |
| 787 | 788 |
| 788 CHECK(Handle<String>::cast(copy_result)->Equals(*expected)); | 789 CHECK(Handle<String>::cast(copy_result)->Equals(*expected)); |
| 789 CHECK_EQ(builtins_count, CountBuiltins()); | 790 CHECK_EQ(builtins_count, CountBuiltins()); |
| 790 | 791 |
| 791 delete cache; | 792 delete cache; |
| 792 } | 793 } |
| OLD | NEW |