Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: src/runtime.cc

Issue 7529007: Preliminary Harmony weak maps API implementation. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 628
629 629
630 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { 630 RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) {
631 ASSERT(args.length() == 1); 631 ASSERT(args.length() == 1);
632 CONVERT_CHECKED(JSProxy, proxy, args[0]); 632 CONVERT_CHECKED(JSProxy, proxy, args[0]);
633 proxy->Fix(); 633 proxy->Fix();
634 return isolate->heap()->undefined_value(); 634 return isolate->heap()->undefined_value();
635 } 635 }
636 636
637 637
638 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapCreate) {
639 HandleScope scope(isolate);
640 ASSERT(args.length() == 1);
641 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0);
642 Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0);
643 weakmap->set_table(*table);
644 return *weakmap;
645 }
646
647
648 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapGet) {
649 ASSERT(args.length() == 2);
650 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0);
651 CONVERT_ARG_CHECKED(JSObject, key, 1);
652 Handle<ObjectHashTable> table(weakmap->table());
653 return table->Lookup(*key);
654 }
655
656
657 RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapSet) {
658 ASSERT(args.length() == 3);
659 CONVERT_ARG_CHECKED(JSWeakMap, weakmap, 0);
660 CONVERT_ARG_CHECKED(JSObject, key, 1);
661 Handle<Object> value(args[2]);
662 Handle<ObjectHashTable> table(weakmap->table());
663 weakmap->set_table(*PutIntoObjectHashTable(table, key, value));
664 return *value;
665 }
666
667
638 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) { 668 RUNTIME_FUNCTION(MaybeObject*, Runtime_ClassOf) {
639 NoHandleAllocation ha; 669 NoHandleAllocation ha;
640 ASSERT(args.length() == 1); 670 ASSERT(args.length() == 1);
641 Object* obj = args[0]; 671 Object* obj = args[0];
642 if (!obj->IsJSObject()) return isolate->heap()->null_value(); 672 if (!obj->IsJSObject()) return isolate->heap()->null_value();
643 return JSObject::cast(obj)->class_name(); 673 return JSObject::cast(obj)->class_name();
644 } 674 }
645 675
646 676
647 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) { 677 RUNTIME_FUNCTION(MaybeObject*, Runtime_GetPrototype) {
(...skipping 12115 matching lines...) Expand 10 before | Expand all | Expand 10 after
12763 } else { 12793 } else {
12764 // Handle last resort GC and make sure to allow future allocations 12794 // Handle last resort GC and make sure to allow future allocations
12765 // to grow the heap without causing GCs (if possible). 12795 // to grow the heap without causing GCs (if possible).
12766 isolate->counters()->gc_last_resort_from_js()->Increment(); 12796 isolate->counters()->gc_last_resort_from_js()->Increment();
12767 isolate->heap()->CollectAllGarbage(false); 12797 isolate->heap()->CollectAllGarbage(false);
12768 } 12798 }
12769 } 12799 }
12770 12800
12771 12801
12772 } } // namespace v8::internal 12802 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/runtime.h ('k') | src/weakmap.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698