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 13140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13151 ASSERT(args.length() == 2); | 13151 ASSERT(args.length() == 2); |
13152 CONVERT_ARG_CHECKED(JSObject, obj1, 0); | 13152 CONVERT_ARG_CHECKED(JSObject, obj1, 0); |
13153 CONVERT_ARG_CHECKED(JSObject, obj2, 1); | 13153 CONVERT_ARG_CHECKED(JSObject, obj2, 1); |
13154 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); | 13154 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); |
13155 } | 13155 } |
13156 | 13156 |
13157 | 13157 |
13158 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { | 13158 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { |
13159 ASSERT(args.length() == 1); | 13159 ASSERT(args.length() == 1); |
13160 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 13160 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
| 13161 if (obj->IsJSGlobalProxy()) { |
| 13162 Object* proto = obj->GetPrototype(); |
| 13163 if (obj->IsNull()) return isolate->heap()->false_value(); |
| 13164 ASSERT(proto->IsJSGlobalObject()); |
| 13165 obj = JSReceiver::cast(proto); |
| 13166 } |
13161 return isolate->heap()->ToBoolean(obj->map()->is_observed()); | 13167 return isolate->heap()->ToBoolean(obj->map()->is_observed()); |
13162 } | 13168 } |
13163 | 13169 |
13164 | 13170 |
13165 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { | 13171 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { |
13166 ASSERT(args.length() == 2); | 13172 ASSERT(args.length() == 2); |
13167 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); | 13173 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); |
13168 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); | 13174 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); |
| 13175 if (obj->IsJSGlobalProxy()) { |
| 13176 Object* proto = obj->GetPrototype(); |
| 13177 if (obj->IsNull()) return isolate->heap()->undefined_value(); |
| 13178 ASSERT(proto->IsJSGlobalObject()); |
| 13179 obj = JSReceiver::cast(proto); |
| 13180 } |
13169 if (obj->map()->is_observed() != is_observed) { | 13181 if (obj->map()->is_observed() != is_observed) { |
13170 MaybeObject* maybe = obj->map()->Copy(); | 13182 MaybeObject* maybe = obj->map()->Copy(); |
13171 Map* map; | 13183 Map* map; |
13172 if (!maybe->To(&map)) return maybe; | 13184 if (!maybe->To(&map)) return maybe; |
13173 map->set_is_observed(is_observed); | 13185 map->set_is_observed(is_observed); |
13174 obj->set_map(map); | 13186 obj->set_map(map); |
13175 } | 13187 } |
13176 return isolate->heap()->undefined_value(); | 13188 return isolate->heap()->undefined_value(); |
13177 } | 13189 } |
13178 | 13190 |
(...skipping 15 matching lines...) Expand all Loading... |
13194 ASSERT(args.length() == 0); | 13206 ASSERT(args.length() == 0); |
13195 return ObjectHashTable::Allocate(0); | 13207 return ObjectHashTable::Allocate(0); |
13196 } | 13208 } |
13197 | 13209 |
13198 | 13210 |
13199 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) { | 13211 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) { |
13200 NoHandleAllocation ha; | 13212 NoHandleAllocation ha; |
13201 ASSERT(args.length() == 2); | 13213 ASSERT(args.length() == 2); |
13202 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); | 13214 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); |
13203 Object* key = args[1]; | 13215 Object* key = args[1]; |
| 13216 if (key->IsJSGlobalProxy()) { |
| 13217 key = key->GetPrototype(); |
| 13218 if (key->IsNull()) return isolate->heap()->undefined_value(); |
| 13219 } |
13204 Object* lookup = table->Lookup(key); | 13220 Object* lookup = table->Lookup(key); |
13205 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup; | 13221 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup; |
13206 } | 13222 } |
13207 | 13223 |
13208 | 13224 |
13209 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) { | 13225 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) { |
13210 HandleScope scope(isolate); | 13226 HandleScope scope(isolate); |
13211 ASSERT(args.length() == 3); | 13227 ASSERT(args.length() == 3); |
13212 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0); | 13228 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0); |
13213 Handle<Object> key = args.at<Object>(1); | 13229 Handle<Object> key = args.at<Object>(1); |
| 13230 if (key->IsJSGlobalProxy()) { |
| 13231 key = handle(key->GetPrototype(), isolate); |
| 13232 if (key->IsNull()) return *table; |
| 13233 } |
13214 Handle<Object> value = args.at<Object>(2); | 13234 Handle<Object> value = args.at<Object>(2); |
13215 return *PutIntoObjectHashTable(table, key, value); | 13235 return *PutIntoObjectHashTable(table, key, value); |
13216 } | 13236 } |
13217 | 13237 |
13218 | 13238 |
13219 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) { | |
13220 NoHandleAllocation ha; | |
13221 ASSERT(args.length() == 2); | |
13222 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); | |
13223 Object* key = args[1]; | |
13224 Object* lookup = table->Lookup(key); | |
13225 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); | |
13226 } | |
13227 | |
13228 | |
13229 // ---------------------------------------------------------------------------- | 13239 // ---------------------------------------------------------------------------- |
13230 // Implementation of Runtime | 13240 // Implementation of Runtime |
13231 | 13241 |
13232 #define F(name, number_of_args, result_size) \ | 13242 #define F(name, number_of_args, result_size) \ |
13233 { Runtime::k##name, Runtime::RUNTIME, #name, \ | 13243 { Runtime::k##name, Runtime::RUNTIME, #name, \ |
13234 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, | 13244 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, |
13235 | 13245 |
13236 | 13246 |
13237 #define I(name, number_of_args, result_size) \ | 13247 #define I(name, number_of_args, result_size) \ |
13238 { Runtime::kInline##name, Runtime::INLINE, \ | 13248 { Runtime::kInline##name, Runtime::INLINE, \ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13305 // Handle last resort GC and make sure to allow future allocations | 13315 // Handle last resort GC and make sure to allow future allocations |
13306 // to grow the heap without causing GCs (if possible). | 13316 // to grow the heap without causing GCs (if possible). |
13307 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13317 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13308 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13318 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13309 "Runtime::PerformGC"); | 13319 "Runtime::PerformGC"); |
13310 } | 13320 } |
13311 } | 13321 } |
13312 | 13322 |
13313 | 13323 |
13314 } } // namespace v8::internal | 13324 } } // namespace v8::internal |
OLD | NEW |