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

Side by Side Diff: src/runtime.cc

Issue 309663005: Split Put into Put and Remove (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add assert and some comments Created 6 years, 6 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
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-dictionary.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 1635 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
1636 } 1636 }
1637 1637
1638 1638
1639 RUNTIME_FUNCTION(Runtime_MapDelete) { 1639 RUNTIME_FUNCTION(Runtime_MapDelete) {
1640 HandleScope scope(isolate); 1640 HandleScope scope(isolate);
1641 ASSERT(args.length() == 2); 1641 ASSERT(args.length() == 2);
1642 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1642 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1643 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1643 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1644 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1644 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1645 Handle<Object> lookup(table->Lookup(key), isolate); 1645 bool was_present = false;
1646 Handle<OrderedHashMap> new_table = 1646 Handle<OrderedHashMap> new_table =
1647 OrderedHashMap::Put(table, key, isolate->factory()->the_hole_value()); 1647 OrderedHashMap::Remove(table, key, &was_present);
1648 holder->set_table(*new_table); 1648 holder->set_table(*new_table);
1649 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 1649 return isolate->heap()->ToBoolean(was_present);
1650 } 1650 }
1651 1651
1652 1652
1653 RUNTIME_FUNCTION(Runtime_MapClear) { 1653 RUNTIME_FUNCTION(Runtime_MapClear) {
1654 HandleScope scope(isolate); 1654 HandleScope scope(isolate);
1655 ASSERT(args.length() == 1); 1655 ASSERT(args.length() == 1);
1656 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0); 1656 CONVERT_ARG_HANDLE_CHECKED(JSMap, holder, 0);
1657 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table())); 1657 Handle<OrderedHashMap> table(OrderedHashMap::cast(holder->table()));
1658 table = OrderedHashMap::Clear(table); 1658 table = OrderedHashMap::Clear(table);
1659 holder->set_table(*table); 1659 holder->set_table(*table);
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 1752
1753 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) { 1753 RUNTIME_FUNCTION(Runtime_WeakCollectionDelete) {
1754 HandleScope scope(isolate); 1754 HandleScope scope(isolate);
1755 ASSERT(args.length() == 2); 1755 ASSERT(args.length() == 2);
1756 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 1756 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
1757 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1757 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1758 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 1758 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
1759 Handle<ObjectHashTable> table(ObjectHashTable::cast( 1759 Handle<ObjectHashTable> table(ObjectHashTable::cast(
1760 weak_collection->table())); 1760 weak_collection->table()));
1761 RUNTIME_ASSERT(table->IsKey(*key)); 1761 RUNTIME_ASSERT(table->IsKey(*key));
1762 Handle<Object> lookup(table->Lookup(key), isolate); 1762 bool was_present = false;
1763 Handle<ObjectHashTable> new_table = 1763 Handle<ObjectHashTable> new_table =
1764 ObjectHashTable::Put(table, key, isolate->factory()->the_hole_value()); 1764 ObjectHashTable::Remove(table, key, &was_present);
1765 weak_collection->set_table(*new_table); 1765 weak_collection->set_table(*new_table);
1766 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 1766 return isolate->heap()->ToBoolean(was_present);
1767 } 1767 }
1768 1768
1769 1769
1770 RUNTIME_FUNCTION(Runtime_WeakCollectionSet) { 1770 RUNTIME_FUNCTION(Runtime_WeakCollectionSet) {
1771 HandleScope scope(isolate); 1771 HandleScope scope(isolate);
1772 ASSERT(args.length() == 3); 1772 ASSERT(args.length() == 3);
1773 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0); 1773 CONVERT_ARG_HANDLE_CHECKED(JSWeakCollection, weak_collection, 0);
1774 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1); 1774 CONVERT_ARG_HANDLE_CHECKED(Object, key, 1);
1775 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol()); 1775 RUNTIME_ASSERT(key->IsJSReceiver() || key->IsSymbol());
1776 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2); 1776 CONVERT_ARG_HANDLE_CHECKED(Object, value, 2);
(...skipping 13381 matching lines...) Expand 10 before | Expand all | Expand 10 after
15158 } 15158 }
15159 return NULL; 15159 return NULL;
15160 } 15160 }
15161 15161
15162 15162
15163 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15163 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15164 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15164 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15165 } 15165 }
15166 15166
15167 } } // namespace v8::internal 15167 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | test/cctest/test-dictionary.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698