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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 HeapIterator iterator(CcTest::heap()); | 725 HeapIterator iterator(CcTest::heap()); |
726 DisallowHeapAllocation no_allocation; | 726 DisallowHeapAllocation no_allocation; |
727 int counter = 0; | 727 int counter = 0; |
728 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { | 728 for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { |
729 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++; | 729 if (obj->IsCode() && Code::cast(obj)->kind() == Code::BUILTIN) counter++; |
730 } | 730 } |
731 return counter; | 731 return counter; |
732 } | 732 } |
733 | 733 |
734 | 734 |
| 735 static Handle<SharedFunctionInfo> CompileScript( |
| 736 Isolate* isolate, Handle<String> source, Handle<String> name, |
| 737 ScriptData** cached_data, v8::ScriptCompiler::CompileOptions options) { |
| 738 return Compiler::CompileScript(source, name, 0, 0, false, false, |
| 739 Handle<Context>(isolate->native_context()), |
| 740 NULL, cached_data, options, NOT_NATIVES_CODE, |
| 741 false); |
| 742 } |
| 743 |
| 744 |
735 TEST(SerializeToplevelOnePlusOne) { | 745 TEST(SerializeToplevelOnePlusOne) { |
736 FLAG_serialize_toplevel = true; | 746 FLAG_serialize_toplevel = true; |
737 LocalContext context; | 747 LocalContext context; |
738 Isolate* isolate = CcTest::i_isolate(); | 748 Isolate* isolate = CcTest::i_isolate(); |
739 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. | 749 isolate->compilation_cache()->Disable(); // Disable same-isolate code cache. |
740 | 750 |
741 v8::HandleScope scope(CcTest::isolate()); | 751 v8::HandleScope scope(CcTest::isolate()); |
742 | 752 |
743 const char* source = "1 + 1"; | 753 const char* source = "1 + 1"; |
744 | 754 |
745 Handle<String> orig_source = isolate->factory() | 755 Handle<String> orig_source = isolate->factory() |
746 ->NewStringFromUtf8(CStrVector(source)) | 756 ->NewStringFromUtf8(CStrVector(source)) |
747 .ToHandleChecked(); | 757 .ToHandleChecked(); |
748 Handle<String> copy_source = isolate->factory() | 758 Handle<String> copy_source = isolate->factory() |
749 ->NewStringFromUtf8(CStrVector(source)) | 759 ->NewStringFromUtf8(CStrVector(source)) |
750 .ToHandleChecked(); | 760 .ToHandleChecked(); |
751 CHECK(!orig_source.is_identical_to(copy_source)); | 761 CHECK(!orig_source.is_identical_to(copy_source)); |
752 CHECK(orig_source->Equals(*copy_source)); | 762 CHECK(orig_source->Equals(*copy_source)); |
753 | 763 |
754 ScriptData* cache = NULL; | 764 ScriptData* cache = NULL; |
755 | 765 |
756 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 766 Handle<SharedFunctionInfo> orig = |
757 orig_source, Handle<String>(), 0, 0, false, false, | 767 CompileScript(isolate, orig_source, Handle<String>(), &cache, |
758 Handle<Context>(isolate->native_context()), NULL, &cache, | 768 v8::ScriptCompiler::kProduceCodeCache); |
759 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
760 | 769 |
761 int builtins_count = CountBuiltins(); | 770 int builtins_count = CountBuiltins(); |
762 | 771 |
763 Handle<SharedFunctionInfo> copy; | 772 Handle<SharedFunctionInfo> copy; |
764 { | 773 { |
765 DisallowCompilation no_compile_expected(isolate); | 774 DisallowCompilation no_compile_expected(isolate); |
766 copy = Compiler::CompileScript( | 775 copy = CompileScript(isolate, copy_source, Handle<String>(), &cache, |
767 copy_source, Handle<String>(), 0, 0, false, false, | 776 v8::ScriptCompiler::kConsumeCodeCache); |
768 Handle<Context>(isolate->native_context()), NULL, &cache, | |
769 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
770 } | 777 } |
771 | 778 |
772 CHECK_NE(*orig, *copy); | 779 CHECK_NE(*orig, *copy); |
773 CHECK(Script::cast(copy->script())->source() == *copy_source); | 780 CHECK(Script::cast(copy->script())->source() == *copy_source); |
774 | 781 |
775 Handle<JSFunction> copy_fun = | 782 Handle<JSFunction> copy_fun = |
776 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 783 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
777 copy, isolate->native_context()); | 784 copy, isolate->native_context()); |
778 Handle<JSObject> global(isolate->context()->global_object()); | 785 Handle<JSObject> global(isolate->context()->global_object()); |
779 Handle<Object> copy_result = | 786 Handle<Object> copy_result = |
(...skipping 21 matching lines...) Expand all Loading... |
801 .ToHandleChecked(); | 808 .ToHandleChecked(); |
802 Handle<String> copy_source = isolate->factory() | 809 Handle<String> copy_source = isolate->factory() |
803 ->NewStringFromUtf8(CStrVector(source)) | 810 ->NewStringFromUtf8(CStrVector(source)) |
804 .ToHandleChecked(); | 811 .ToHandleChecked(); |
805 CHECK(!orig_source.is_identical_to(copy_source)); | 812 CHECK(!orig_source.is_identical_to(copy_source)); |
806 CHECK(orig_source->Equals(*copy_source)); | 813 CHECK(orig_source->Equals(*copy_source)); |
807 | 814 |
808 Handle<JSObject> global(isolate->context()->global_object()); | 815 Handle<JSObject> global(isolate->context()->global_object()); |
809 ScriptData* cache = NULL; | 816 ScriptData* cache = NULL; |
810 | 817 |
811 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 818 Handle<SharedFunctionInfo> orig = |
812 orig_source, Handle<String>(), 0, 0, false, false, | 819 CompileScript(isolate, orig_source, Handle<String>(), &cache, |
813 Handle<Context>(isolate->native_context()), NULL, &cache, | 820 v8::ScriptCompiler::kProduceCodeCache); |
814 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
815 Handle<JSFunction> orig_fun = | 821 Handle<JSFunction> orig_fun = |
816 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 822 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
817 orig, isolate->native_context()); | 823 orig, isolate->native_context()); |
818 Handle<Object> orig_result = | 824 Handle<Object> orig_result = |
819 Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked(); | 825 Execution::Call(isolate, orig_fun, global, 0, NULL).ToHandleChecked(); |
820 CHECK(orig_result->IsInternalizedString()); | 826 CHECK(orig_result->IsInternalizedString()); |
821 | 827 |
822 int builtins_count = CountBuiltins(); | 828 int builtins_count = CountBuiltins(); |
823 | 829 |
824 Handle<SharedFunctionInfo> copy; | 830 Handle<SharedFunctionInfo> copy; |
825 { | 831 { |
826 DisallowCompilation no_compile_expected(isolate); | 832 DisallowCompilation no_compile_expected(isolate); |
827 copy = Compiler::CompileScript( | 833 copy = CompileScript(isolate, copy_source, Handle<String>(), &cache, |
828 copy_source, Handle<String>(), 0, 0, false, false, | 834 v8::ScriptCompiler::kConsumeCodeCache); |
829 Handle<Context>(isolate->native_context()), NULL, &cache, | |
830 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
831 } | 835 } |
832 CHECK_NE(*orig, *copy); | 836 CHECK_NE(*orig, *copy); |
833 CHECK(Script::cast(copy->script())->source() == *copy_source); | 837 CHECK(Script::cast(copy->script())->source() == *copy_source); |
834 | 838 |
835 Handle<JSFunction> copy_fun = | 839 Handle<JSFunction> copy_fun = |
836 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 840 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
837 copy, isolate->native_context()); | 841 copy, isolate->native_context()); |
838 CHECK_NE(*orig_fun, *copy_fun); | 842 CHECK_NE(*orig_fun, *copy_fun); |
839 Handle<Object> copy_result = | 843 Handle<Object> copy_result = |
840 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 844 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
(...skipping 19 matching lines...) Expand all Loading... |
860 Vector<const uint8_t> source = | 864 Vector<const uint8_t> source = |
861 ConstructSource(STATIC_CHAR_VECTOR("var j=1; try { if (j) throw 1;"), | 865 ConstructSource(STATIC_CHAR_VECTOR("var j=1; try { if (j) throw 1;"), |
862 STATIC_CHAR_VECTOR("for(var i=0;i<1;i++)j++;"), | 866 STATIC_CHAR_VECTOR("for(var i=0;i<1;i++)j++;"), |
863 STATIC_CHAR_VECTOR("} catch (e) { j=7; } j"), 10000); | 867 STATIC_CHAR_VECTOR("} catch (e) { j=7; } j"), 10000); |
864 Handle<String> source_str = | 868 Handle<String> source_str = |
865 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); | 869 isolate->factory()->NewStringFromOneByte(source).ToHandleChecked(); |
866 | 870 |
867 Handle<JSObject> global(isolate->context()->global_object()); | 871 Handle<JSObject> global(isolate->context()->global_object()); |
868 ScriptData* cache = NULL; | 872 ScriptData* cache = NULL; |
869 | 873 |
870 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 874 Handle<SharedFunctionInfo> orig = |
871 source_str, Handle<String>(), 0, 0, false, false, | 875 CompileScript(isolate, source_str, Handle<String>(), &cache, |
872 Handle<Context>(isolate->native_context()), NULL, &cache, | 876 v8::ScriptCompiler::kProduceCodeCache); |
873 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
874 | 877 |
875 CHECK(isolate->heap()->InSpace(orig->code(), LO_SPACE)); | 878 CHECK(isolate->heap()->InSpace(orig->code(), LO_SPACE)); |
876 | 879 |
877 Handle<SharedFunctionInfo> copy; | 880 Handle<SharedFunctionInfo> copy; |
878 { | 881 { |
879 DisallowCompilation no_compile_expected(isolate); | 882 DisallowCompilation no_compile_expected(isolate); |
880 copy = Compiler::CompileScript( | 883 copy = CompileScript(isolate, source_str, Handle<String>(), &cache, |
881 source_str, Handle<String>(), 0, 0, false, false, | 884 v8::ScriptCompiler::kConsumeCodeCache); |
882 Handle<Context>(isolate->native_context()), NULL, &cache, | |
883 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
884 } | 885 } |
885 CHECK_NE(*orig, *copy); | 886 CHECK_NE(*orig, *copy); |
886 | 887 |
887 Handle<JSFunction> copy_fun = | 888 Handle<JSFunction> copy_fun = |
888 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 889 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
889 copy, isolate->native_context()); | 890 copy, isolate->native_context()); |
890 | 891 |
891 Handle<Object> copy_result = | 892 Handle<Object> copy_result = |
892 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 893 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
893 | 894 |
(...skipping 22 matching lines...) Expand all Loading... |
916 STATIC_CHAR_VECTOR("var t = \""), STATIC_CHAR_VECTOR("uvwxyz"), | 917 STATIC_CHAR_VECTOR("var t = \""), STATIC_CHAR_VECTOR("uvwxyz"), |
917 STATIC_CHAR_VECTOR("\"; s + t"), 999999); | 918 STATIC_CHAR_VECTOR("\"; s + t"), 999999); |
918 Handle<String> source_str = | 919 Handle<String> source_str = |
919 f->NewConsString(f->NewStringFromOneByte(source_s).ToHandleChecked(), | 920 f->NewConsString(f->NewStringFromOneByte(source_s).ToHandleChecked(), |
920 f->NewStringFromOneByte(source_t).ToHandleChecked()) | 921 f->NewStringFromOneByte(source_t).ToHandleChecked()) |
921 .ToHandleChecked(); | 922 .ToHandleChecked(); |
922 | 923 |
923 Handle<JSObject> global(isolate->context()->global_object()); | 924 Handle<JSObject> global(isolate->context()->global_object()); |
924 ScriptData* cache = NULL; | 925 ScriptData* cache = NULL; |
925 | 926 |
926 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 927 Handle<SharedFunctionInfo> orig = |
927 source_str, Handle<String>(), 0, 0, false, false, | 928 CompileScript(isolate, source_str, Handle<String>(), &cache, |
928 Handle<Context>(isolate->native_context()), NULL, &cache, | 929 v8::ScriptCompiler::kProduceCodeCache); |
929 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
930 | 930 |
931 Handle<SharedFunctionInfo> copy; | 931 Handle<SharedFunctionInfo> copy; |
932 { | 932 { |
933 DisallowCompilation no_compile_expected(isolate); | 933 DisallowCompilation no_compile_expected(isolate); |
934 copy = Compiler::CompileScript( | 934 copy = CompileScript(isolate, source_str, Handle<String>(), &cache, |
935 source_str, Handle<String>(), 0, 0, false, false, | 935 v8::ScriptCompiler::kConsumeCodeCache); |
936 Handle<Context>(isolate->native_context()), NULL, &cache, | |
937 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
938 } | 936 } |
939 CHECK_NE(*orig, *copy); | 937 CHECK_NE(*orig, *copy); |
940 | 938 |
941 Handle<JSFunction> copy_fun = | 939 Handle<JSFunction> copy_fun = |
942 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 940 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
943 copy, isolate->native_context()); | 941 copy, isolate->native_context()); |
944 | 942 |
945 Handle<Object> copy_result = | 943 Handle<Object> copy_result = |
946 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 944 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
947 | 945 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 f->NewStringFromOneByte(source_c).ToHandleChecked(); | 987 f->NewStringFromOneByte(source_c).ToHandleChecked(); |
990 | 988 |
991 Handle<String> source_str = | 989 Handle<String> source_str = |
992 f->NewConsString( | 990 f->NewConsString( |
993 f->NewConsString(source_a_str, source_b_str).ToHandleChecked(), | 991 f->NewConsString(source_a_str, source_b_str).ToHandleChecked(), |
994 source_c_str).ToHandleChecked(); | 992 source_c_str).ToHandleChecked(); |
995 | 993 |
996 Handle<JSObject> global(isolate->context()->global_object()); | 994 Handle<JSObject> global(isolate->context()->global_object()); |
997 ScriptData* cache = NULL; | 995 ScriptData* cache = NULL; |
998 | 996 |
999 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 997 Handle<SharedFunctionInfo> orig = |
1000 source_str, Handle<String>(), 0, 0, false, false, | 998 CompileScript(isolate, source_str, Handle<String>(), &cache, |
1001 Handle<Context>(isolate->native_context()), NULL, &cache, | 999 v8::ScriptCompiler::kProduceCodeCache); |
1002 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
1003 | 1000 |
1004 Handle<SharedFunctionInfo> copy; | 1001 Handle<SharedFunctionInfo> copy; |
1005 { | 1002 { |
1006 DisallowCompilation no_compile_expected(isolate); | 1003 DisallowCompilation no_compile_expected(isolate); |
1007 copy = Compiler::CompileScript( | 1004 copy = CompileScript(isolate, source_str, Handle<String>(), &cache, |
1008 source_str, Handle<String>(), 0, 0, false, false, | 1005 v8::ScriptCompiler::kConsumeCodeCache); |
1009 Handle<Context>(isolate->native_context()), NULL, &cache, | |
1010 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
1011 } | 1006 } |
1012 CHECK_NE(*orig, *copy); | 1007 CHECK_NE(*orig, *copy); |
1013 | 1008 |
1014 Handle<JSFunction> copy_fun = | 1009 Handle<JSFunction> copy_fun = |
1015 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1010 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1016 copy, isolate->native_context()); | 1011 copy, isolate->native_context()); |
1017 | 1012 |
1018 USE(Execution::Call(isolate, copy_fun, global, 0, NULL)); | 1013 USE(Execution::Call(isolate, copy_fun, global, 0, NULL)); |
1019 | 1014 |
1020 CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value()); | 1015 CHECK_EQ(600000 + 700000, CompileRun("(a + b).length")->Int32Value()); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1097 "o.one_byte = 7; \n" | 1092 "o.one_byte = 7; \n" |
1098 "o.two_byte = 8; \n" | 1093 "o.two_byte = 8; \n" |
1099 "o.one_byte + o.two_byte; \n"; | 1094 "o.one_byte + o.two_byte; \n"; |
1100 Handle<String> source_string = isolate->factory() | 1095 Handle<String> source_string = isolate->factory() |
1101 ->NewStringFromUtf8(CStrVector(source)) | 1096 ->NewStringFromUtf8(CStrVector(source)) |
1102 .ToHandleChecked(); | 1097 .ToHandleChecked(); |
1103 | 1098 |
1104 Handle<JSObject> global(isolate->context()->global_object()); | 1099 Handle<JSObject> global(isolate->context()->global_object()); |
1105 ScriptData* cache = NULL; | 1100 ScriptData* cache = NULL; |
1106 | 1101 |
1107 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 1102 Handle<SharedFunctionInfo> orig = |
1108 source_string, Handle<String>(), 0, 0, false, false, | 1103 CompileScript(isolate, source_string, Handle<String>(), &cache, |
1109 Handle<Context>(isolate->native_context()), NULL, &cache, | 1104 v8::ScriptCompiler::kProduceCodeCache); |
1110 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
1111 | 1105 |
1112 Handle<SharedFunctionInfo> copy; | 1106 Handle<SharedFunctionInfo> copy; |
1113 { | 1107 { |
1114 DisallowCompilation no_compile_expected(isolate); | 1108 DisallowCompilation no_compile_expected(isolate); |
1115 copy = Compiler::CompileScript( | 1109 copy = CompileScript(isolate, source_string, Handle<String>(), &cache, |
1116 source_string, Handle<String>(), 0, 0, false, false, | 1110 v8::ScriptCompiler::kConsumeCodeCache); |
1117 Handle<Context>(isolate->native_context()), NULL, &cache, | |
1118 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
1119 } | 1111 } |
1120 CHECK_NE(*orig, *copy); | 1112 CHECK_NE(*orig, *copy); |
1121 | 1113 |
1122 Handle<JSFunction> copy_fun = | 1114 Handle<JSFunction> copy_fun = |
1123 isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1115 isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1124 copy, isolate->native_context()); | 1116 copy, isolate->native_context()); |
1125 | 1117 |
1126 Handle<Object> copy_result = | 1118 Handle<Object> copy_result = |
1127 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 1119 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
1128 | 1120 |
(...skipping 30 matching lines...) Expand all Loading... |
1159 Handle<String> source_str = | 1151 Handle<String> source_str = |
1160 f->NewConsString( | 1152 f->NewConsString( |
1161 f->NewConsString(f->NewStringFromAsciiChecked("var "), name) | 1153 f->NewConsString(f->NewStringFromAsciiChecked("var "), name) |
1162 .ToHandleChecked(), | 1154 .ToHandleChecked(), |
1163 f->NewConsString(f->NewStringFromAsciiChecked(" = 42; "), name) | 1155 f->NewConsString(f->NewStringFromAsciiChecked(" = 42; "), name) |
1164 .ToHandleChecked()).ToHandleChecked(); | 1156 .ToHandleChecked()).ToHandleChecked(); |
1165 | 1157 |
1166 Handle<JSObject> global(isolate->context()->global_object()); | 1158 Handle<JSObject> global(isolate->context()->global_object()); |
1167 ScriptData* cache = NULL; | 1159 ScriptData* cache = NULL; |
1168 | 1160 |
1169 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 1161 Handle<SharedFunctionInfo> orig = |
1170 source_str, Handle<String>(), 0, 0, false, false, | 1162 CompileScript(isolate, source_str, Handle<String>(), &cache, |
1171 Handle<Context>(isolate->native_context()), NULL, &cache, | 1163 v8::ScriptCompiler::kProduceCodeCache); |
1172 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
1173 | 1164 |
1174 Handle<SharedFunctionInfo> copy; | 1165 Handle<SharedFunctionInfo> copy; |
1175 { | 1166 { |
1176 DisallowCompilation no_compile_expected(isolate); | 1167 DisallowCompilation no_compile_expected(isolate); |
1177 copy = Compiler::CompileScript( | 1168 copy = CompileScript(isolate, source_str, Handle<String>(), &cache, |
1178 source_str, Handle<String>(), 0, 0, false, false, | 1169 v8::ScriptCompiler::kConsumeCodeCache); |
1179 Handle<Context>(isolate->native_context()), NULL, &cache, | |
1180 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
1181 } | 1170 } |
1182 CHECK_NE(*orig, *copy); | 1171 CHECK_NE(*orig, *copy); |
1183 | 1172 |
1184 Handle<JSFunction> copy_fun = | 1173 Handle<JSFunction> copy_fun = |
1185 f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context()); | 1174 f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context()); |
1186 | 1175 |
1187 Handle<Object> copy_result = | 1176 Handle<Object> copy_result = |
1188 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 1177 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
1189 | 1178 |
1190 CHECK_EQ(42.0f, copy_result->Number()); | 1179 CHECK_EQ(42.0f, copy_result->Number()); |
(...skipping 22 matching lines...) Expand all Loading... |
1213 | 1202 |
1214 const SerializerOneByteResource one_byte_resource("one_byte", 8); | 1203 const SerializerOneByteResource one_byte_resource("one_byte", 8); |
1215 Handle<String> name = | 1204 Handle<String> name = |
1216 f->NewExternalStringFromOneByte(&one_byte_resource).ToHandleChecked(); | 1205 f->NewExternalStringFromOneByte(&one_byte_resource).ToHandleChecked(); |
1217 CHECK(name->IsExternalOneByteString()); | 1206 CHECK(name->IsExternalOneByteString()); |
1218 CHECK(!name->IsInternalizedString()); | 1207 CHECK(!name->IsInternalizedString()); |
1219 | 1208 |
1220 Handle<JSObject> global(isolate->context()->global_object()); | 1209 Handle<JSObject> global(isolate->context()->global_object()); |
1221 ScriptData* cache = NULL; | 1210 ScriptData* cache = NULL; |
1222 | 1211 |
1223 Handle<SharedFunctionInfo> orig = Compiler::CompileScript( | 1212 Handle<SharedFunctionInfo> orig = |
1224 source_string, name, 0, 0, false, false, | 1213 CompileScript(isolate, source_string, name, &cache, |
1225 Handle<Context>(isolate->native_context()), NULL, &cache, | 1214 v8::ScriptCompiler::kProduceCodeCache); |
1226 v8::ScriptCompiler::kProduceCodeCache, NOT_NATIVES_CODE); | |
1227 | 1215 |
1228 Handle<SharedFunctionInfo> copy; | 1216 Handle<SharedFunctionInfo> copy; |
1229 { | 1217 { |
1230 DisallowCompilation no_compile_expected(isolate); | 1218 DisallowCompilation no_compile_expected(isolate); |
1231 copy = Compiler::CompileScript( | 1219 copy = CompileScript(isolate, source_string, name, &cache, |
1232 source_string, name, 0, 0, false, false, | 1220 v8::ScriptCompiler::kConsumeCodeCache); |
1233 Handle<Context>(isolate->native_context()), NULL, &cache, | |
1234 v8::ScriptCompiler::kConsumeCodeCache, NOT_NATIVES_CODE); | |
1235 } | 1221 } |
1236 CHECK_NE(*orig, *copy); | 1222 CHECK_NE(*orig, *copy); |
1237 | 1223 |
1238 Handle<JSFunction> copy_fun = | 1224 Handle<JSFunction> copy_fun = |
1239 f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context()); | 1225 f->NewFunctionFromSharedFunctionInfo(copy, isolate->native_context()); |
1240 | 1226 |
1241 Handle<Object> copy_result = | 1227 Handle<Object> copy_result = |
1242 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); | 1228 Execution::Call(isolate, copy_fun, global, 0, NULL).ToHandleChecked(); |
1243 | 1229 |
1244 CHECK_EQ(10.0f, copy_result->Number()); | 1230 CHECK_EQ(10.0f, copy_result->Number()); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 { | 1359 { |
1374 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); | 1360 DisallowCompilation no_compile(reinterpret_cast<Isolate*>(isolate2)); |
1375 script = v8::ScriptCompiler::CompileUnbound( | 1361 script = v8::ScriptCompiler::CompileUnbound( |
1376 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); | 1362 isolate2, &source, v8::ScriptCompiler::kConsumeCodeCache); |
1377 } | 1363 } |
1378 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); | 1364 v8::Local<v8::Value> result = script->BindToCurrentContext()->Run(); |
1379 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); | 1365 CHECK(result->ToString(isolate2)->Equals(v8_str("XY"))); |
1380 } | 1366 } |
1381 isolate2->Dispose(); | 1367 isolate2->Dispose(); |
1382 } | 1368 } |
OLD | NEW |