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 881 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 ASSERT(args.length() == 1); | 892 ASSERT(args.length() == 1); |
893 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 893 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
894 return WeakMapInitialize(isolate, weakmap); | 894 return WeakMapInitialize(isolate, weakmap); |
895 } | 895 } |
896 | 896 |
897 | 897 |
898 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { | 898 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
899 HandleScope scope(isolate); | 899 HandleScope scope(isolate); |
900 ASSERT(args.length() == 2); | 900 ASSERT(args.length() == 2); |
901 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 901 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
902 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 902 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
903 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 903 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
904 Handle<Object> lookup(table->Lookup(*key), isolate); | 904 Handle<Object> lookup(table->Lookup(*key), isolate); |
905 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 905 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
906 } | 906 } |
907 | 907 |
908 | 908 |
909 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { | 909 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapHas) { |
910 HandleScope scope(isolate); | 910 HandleScope scope(isolate); |
911 ASSERT(args.length() == 2); | 911 ASSERT(args.length() == 2); |
912 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 912 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
913 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 913 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
914 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 914 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
915 Handle<Object> lookup(table->Lookup(*key), isolate); | 915 Handle<Object> lookup(table->Lookup(*key), isolate); |
916 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 916 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
917 } | 917 } |
918 | 918 |
919 | 919 |
920 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { | 920 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapDelete) { |
921 HandleScope scope(isolate); | 921 HandleScope scope(isolate); |
922 ASSERT(args.length() == 2); | 922 ASSERT(args.length() == 2); |
923 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 923 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
924 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 924 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
925 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 925 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
926 Handle<Object> lookup(table->Lookup(*key), isolate); | 926 Handle<Object> lookup(table->Lookup(*key), isolate); |
927 Handle<ObjectHashTable> new_table = | 927 Handle<ObjectHashTable> new_table = |
928 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); | 928 PutIntoObjectHashTable(table, key, isolate->factory()->the_hole_value()); |
929 weakmap->set_table(*new_table); | 929 weakmap->set_table(*new_table); |
930 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | 930 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); |
931 } | 931 } |
932 | 932 |
933 | 933 |
934 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { | 934 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) { |
935 HandleScope scope(isolate); | 935 HandleScope scope(isolate); |
936 ASSERT(args.length() == 3); | 936 ASSERT(args.length() == 3); |
937 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 937 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
938 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 938 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); |
939 Handle<Object> value(args[2], isolate); | 939 Handle<Object> value(args[2], isolate); |
940 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 940 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
941 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); | 941 Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
942 weakmap->set_table(*new_table); | 942 weakmap->set_table(*new_table); |
943 return isolate->heap()->undefined_value(); | 943 return isolate->heap()->undefined_value(); |
944 } | 944 } |
945 | 945 |
946 | 946 |
947 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { | 947 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { |
948 NoHandleAllocation ha(isolate); | 948 NoHandleAllocation ha(isolate); |
(...skipping 12365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13314 // Handle last resort GC and make sure to allow future allocations | 13314 // Handle last resort GC and make sure to allow future allocations |
13315 // to grow the heap without causing GCs (if possible). | 13315 // to grow the heap without causing GCs (if possible). |
13316 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13316 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13317 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13317 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13318 "Runtime::PerformGC"); | 13318 "Runtime::PerformGC"); |
13319 } | 13319 } |
13320 } | 13320 } |
13321 | 13321 |
13322 | 13322 |
13323 } } // namespace v8::internal | 13323 } } // namespace v8::internal |
OLD | NEW |