Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index efb7aeeccdf6288740a073f39b82c1ee4d3aaaac..69782afbee2a3a1206c5dbd9eb1c873438ef1973 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -717,6 +717,80 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_Fix) { |
| } |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SetInitialize) { |
| + HandleScope scope(isolate); |
| + ASSERT(args.length() == 1); |
| + CONVERT_ARG_CHECKED(JSSet, holder, 0); |
| + Handle<ObjectHashSet> table = isolate->factory()->NewObjectHashSet(0); |
| + holder->set_table(*table); |
| + return *holder; |
| +} |
| + |
| + |
| +// Enumeration of operation types for Runtime_SetAccess. |
| +enum SetAccessOperation { |
|
rossberg
2011/10/24 15:44:11
I'm not sure I like this. The amount of code it sa
Michael Starzinger
2011/10/25 11:17:26
Done.
|
| + SET_ACCESS_ADD, |
| + SET_ACCESS_HAS, |
| + SET_ACCESS_DELETE |
| +}; |
| + |
| + |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_SetAccess) { |
| + HandleScope scope(isolate); |
| + ASSERT(args.length() == 3); |
| + CONVERT_ARG_CHECKED(JSSet, holder, 0); |
| + CONVERT_SMI_ARG_CHECKED(mode, 2); |
| + Handle<Object> key(args[1]); |
| + Handle<ObjectHashSet> table(ObjectHashSet::cast(holder->table())); |
| + switch (mode) { |
| + case SET_ACCESS_HAS: |
| + return isolate->heap()->ToBoolean(table->Contains(*key)); |
| + case SET_ACCESS_ADD: |
| + table = ObjectHashSetAdd(table, key); |
| + holder->set_table(*table); |
| + return isolate->heap()->undefined_symbol(); |
| + case SET_ACCESS_DELETE: |
| + table = ObjectHashSetRemove(table, key); |
| + holder->set_table(*table); |
| + return isolate->heap()->undefined_symbol(); |
| + } |
| + UNREACHABLE(); |
| + return isolate->heap()->undefined_symbol(); |
| +} |
| + |
| + |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_MapInitialize) { |
| + HandleScope scope(isolate); |
| + ASSERT(args.length() == 1); |
| + CONVERT_ARG_CHECKED(JSMap, holder, 0); |
| + Handle<ObjectHashTable> table = isolate->factory()->NewObjectHashTable(0); |
| + holder->set_table(*table); |
| + return *holder; |
| +} |
| + |
| + |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_MapGet) { |
| + NoHandleAllocation ha; |
| + ASSERT(args.length() == 2); |
| + CONVERT_ARG_CHECKED(JSMap, holder, 0); |
| + CONVERT_ARG_CHECKED(JSReceiver, key, 1); |
|
rossberg
2011/10/24 15:44:11
Why is the key still a JSReceiver here (and below)
Michael Starzinger
2011/10/25 11:17:26
Done (fixed by second patch set).
|
| + return ObjectHashTable::cast(holder->table())->Lookup(*key); |
| +} |
| + |
| + |
| +RUNTIME_FUNCTION(MaybeObject*, Runtime_MapSet) { |
| + HandleScope scope(isolate); |
| + ASSERT(args.length() == 3); |
| + CONVERT_ARG_CHECKED(JSMap, holder, 0); |
| + CONVERT_ARG_CHECKED(JSReceiver, key, 1); |
| + Handle<Object> value(args[2]); |
| + Handle<ObjectHashTable> table(ObjectHashTable::cast(holder->table())); |
| + Handle<ObjectHashTable> new_table = PutIntoObjectHashTable(table, key, value); |
| + holder->set_table(*new_table); |
| + return *value; |
| +} |
| + |
| + |
| RUNTIME_FUNCTION(MaybeObject*, Runtime_WeakMapInitialize) { |
| HandleScope scope(isolate); |
| ASSERT(args.length() == 1); |