| 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 856 | 856 |
| 857 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) { | 857 RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGetSize) { |
| 858 HandleScope scope(isolate); | 858 HandleScope scope(isolate); |
| 859 ASSERT(args.length() == 1); | 859 ASSERT(args.length() == 1); |
| 860 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); | 860 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); |
| 861 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); | 861 Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| 862 return Smi::FromInt(table->NumberOfElements()); | 862 return Smi::FromInt(table->NumberOfElements()); |
| 863 } | 863 } |
| 864 | 864 |
| 865 | 865 |
| 866 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { | 866 static JSWeakMap* WeakMapInitialize(Isolate* isolate, |
| 867 HandleScope scope(isolate); | 867 Handle<JSWeakMap> weakmap) { |
| 868 ASSERT(args.length() == 1); | |
| 869 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | |
| 870 ASSERT(weakmap->map()->inobject_properties() == 0); | 868 ASSERT(weakmap->map()->inobject_properties() == 0); |
| 871 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); | 869 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| 872 weakmap->set_table(*table); | 870 weakmap->set_table(*table); |
| 873 weakmap->set_next(Smi::FromInt(0)); | 871 weakmap->set_next(Smi::FromInt(0)); |
| 874 return *weakmap; | 872 return *weakmap; |
| 875 } | 873 } |
| 876 | 874 |
| 877 | 875 |
| 876 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { |
| 877 HandleScope scope(isolate); |
| 878 ASSERT(args.length() == 1); |
| 879 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 880 return WeakMapInitialize(isolate, weakmap); |
| 881 } |
| 882 |
| 883 |
| 878 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { | 884 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) { |
| 879 HandleScope scope(isolate); | 885 HandleScope scope(isolate); |
| 880 ASSERT(args.length() == 2); | 886 ASSERT(args.length() == 2); |
| 881 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); | 887 CONVERT_ARG_HANDLE_CHECKED(JSWeakMap, weakmap, 0); |
| 882 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); | 888 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, key, 1); |
| 883 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); | 889 Handle<ObjectHashTable> table(ObjectHashTable::cast(weakmap->table())); |
| 884 Handle<Object> lookup(table->Lookup(*key)); | 890 Handle<Object> lookup(table->Lookup(*key)); |
| 885 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; | 891 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : *lookup; |
| 886 } | 892 } |
| 887 | 893 |
| (...skipping 12509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13397 return isolate->heap()->undefined_value(); | 13403 return isolate->heap()->undefined_value(); |
| 13398 } | 13404 } |
| 13399 | 13405 |
| 13400 | 13406 |
| 13401 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { | 13407 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetObservationState) { |
| 13402 ASSERT(args.length() == 0); | 13408 ASSERT(args.length() == 0); |
| 13403 return isolate->heap()->observation_state(); | 13409 return isolate->heap()->observation_state(); |
| 13404 } | 13410 } |
| 13405 | 13411 |
| 13406 | 13412 |
| 13407 RUNTIME_FUNCTION(MaybeObject*, Runtime_CreateObjectHashTable) { | 13413 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObservationWeakMapCreate) { |
| 13414 HandleScope scope(isolate); |
| 13408 ASSERT(args.length() == 0); | 13415 ASSERT(args.length() == 0); |
| 13409 return ObjectHashTable::Allocate(0); | 13416 // TODO(adamk): Currently this runtime function is only called three times per |
| 13417 // isolate. If it's called more often, the map should be moved into the |
| 13418 // strong root list. |
| 13419 Handle<Map> map = |
| 13420 isolate->factory()->NewMap(JS_WEAK_MAP_TYPE, JSWeakMap::kSize); |
| 13421 Handle<JSWeakMap> weakmap = |
| 13422 Handle<JSWeakMap>::cast(isolate->factory()->NewJSObjectFromMap(map)); |
| 13423 return WeakMapInitialize(isolate, weakmap); |
| 13410 } | 13424 } |
| 13411 | 13425 |
| 13412 | 13426 |
| 13413 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) { | 13427 RUNTIME_FUNCTION(MaybeObject*, Runtime_UnwrapGlobalProxy) { |
| 13414 NoHandleAllocation ha; | 13428 ASSERT(args.length() == 1); |
| 13415 ASSERT(args.length() == 2); | 13429 Object* object = args[0]; |
| 13416 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); | 13430 if (object->IsJSGlobalProxy()) { |
| 13417 Object* key = args[1]; | 13431 object = object->GetPrototype(); |
| 13418 if (key->IsJSGlobalProxy()) { | 13432 if (object->IsNull()) return isolate->heap()->undefined_value(); |
| 13419 key = key->GetPrototype(); | |
| 13420 if (key->IsNull()) return isolate->heap()->undefined_value(); | |
| 13421 } | 13433 } |
| 13422 Object* lookup = table->Lookup(key); | 13434 return object; |
| 13423 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup; | |
| 13424 } | 13435 } |
| 13425 | 13436 |
| 13426 | 13437 |
| 13427 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) { | |
| 13428 HandleScope scope(isolate); | |
| 13429 ASSERT(args.length() == 3); | |
| 13430 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0); | |
| 13431 Handle<Object> key = args.at<Object>(1); | |
| 13432 if (key->IsJSGlobalProxy()) { | |
| 13433 key = handle(key->GetPrototype(), isolate); | |
| 13434 if (key->IsNull()) return *table; | |
| 13435 } | |
| 13436 Handle<Object> value = args.at<Object>(2); | |
| 13437 return *PutIntoObjectHashTable(table, key, value); | |
| 13438 } | |
| 13439 | |
| 13440 | |
| 13441 // ---------------------------------------------------------------------------- | 13438 // ---------------------------------------------------------------------------- |
| 13442 // Implementation of Runtime | 13439 // Implementation of Runtime |
| 13443 | 13440 |
| 13444 #define F(name, number_of_args, result_size) \ | 13441 #define F(name, number_of_args, result_size) \ |
| 13445 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 13442 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
| 13446 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 13443 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
| 13447 | 13444 |
| 13448 | 13445 |
| 13449 #define I(name, number_of_args, result_size) \ | 13446 #define I(name, number_of_args, result_size) \ |
| 13450 { Runtime::kInline##name, Runtime::INLINE, \ | 13447 { Runtime::kInline##name, Runtime::INLINE, \ |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13517 // Handle last resort GC and make sure to allow future allocations | 13514 // Handle last resort GC and make sure to allow future allocations |
| 13518 // to grow the heap without causing GCs (if possible). | 13515 // to grow the heap without causing GCs (if possible). |
| 13519 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13516 isolate->counters()->gc_last_resort_from_js()->Increment(); |
| 13520 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13517 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
| 13521 "Runtime::PerformGC"); | 13518 "Runtime::PerformGC"); |
| 13522 } | 13519 } |
| 13523 } | 13520 } |
| 13524 | 13521 |
| 13525 | 13522 |
| 13526 } } // namespace v8::internal | 13523 } } // namespace v8::internal |
| OLD | NEW |