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

Side by Side Diff: src/runtime.cc

Issue 11414094: Make Object.observe on the global object functional (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test for attaching via Context::New Created 8 years 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/runtime.h ('k') | test/cctest/test-object-observe.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 // 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 13253 matching lines...) Expand 10 before | Expand all | Expand 10 after
13264 ASSERT(args.length() == 2); 13264 ASSERT(args.length() == 2);
13265 CONVERT_ARG_CHECKED(JSObject, obj1, 0); 13265 CONVERT_ARG_CHECKED(JSObject, obj1, 0);
13266 CONVERT_ARG_CHECKED(JSObject, obj2, 1); 13266 CONVERT_ARG_CHECKED(JSObject, obj2, 1);
13267 return isolate->heap()->ToBoolean(obj1->map() == obj2->map()); 13267 return isolate->heap()->ToBoolean(obj1->map() == obj2->map());
13268 } 13268 }
13269 13269
13270 13270
13271 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) { 13271 RUNTIME_FUNCTION(MaybeObject*, Runtime_IsObserved) {
13272 ASSERT(args.length() == 1); 13272 ASSERT(args.length() == 1);
13273 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 13273 CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
13274 if (obj->IsJSGlobalProxy()) {
13275 Object* proto = obj->GetPrototype();
13276 if (obj->IsNull()) return isolate->heap()->false_value();
13277 ASSERT(proto->IsJSGlobalObject());
13278 obj = JSReceiver::cast(proto);
13279 }
13274 return isolate->heap()->ToBoolean(obj->map()->is_observed()); 13280 return isolate->heap()->ToBoolean(obj->map()->is_observed());
13275 } 13281 }
13276 13282
13277 13283
13278 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) { 13284 RUNTIME_FUNCTION(MaybeObject*, Runtime_SetIsObserved) {
13279 ASSERT(args.length() == 2); 13285 ASSERT(args.length() == 2);
13280 CONVERT_ARG_CHECKED(JSReceiver, obj, 0); 13286 CONVERT_ARG_CHECKED(JSReceiver, obj, 0);
13281 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1); 13287 CONVERT_BOOLEAN_ARG_CHECKED(is_observed, 1);
13288 if (obj->IsJSGlobalProxy()) {
13289 Object* proto = obj->GetPrototype();
13290 if (obj->IsNull()) return isolate->heap()->undefined_value();
13291 ASSERT(proto->IsJSGlobalObject());
13292 obj = JSReceiver::cast(proto);
13293 }
13282 if (obj->map()->is_observed() != is_observed) { 13294 if (obj->map()->is_observed() != is_observed) {
13283 MaybeObject* maybe = obj->map()->Copy(); 13295 MaybeObject* maybe = obj->map()->Copy();
13284 Map* map; 13296 Map* map;
13285 if (!maybe->To(&map)) return maybe; 13297 if (!maybe->To(&map)) return maybe;
13286 map->set_is_observed(is_observed); 13298 map->set_is_observed(is_observed);
13287 obj->set_map(map); 13299 obj->set_map(map);
13288 } 13300 }
13289 return isolate->heap()->undefined_value(); 13301 return isolate->heap()->undefined_value();
13290 } 13302 }
13291 13303
(...skipping 15 matching lines...) Expand all
13307 ASSERT(args.length() == 0); 13319 ASSERT(args.length() == 0);
13308 return ObjectHashTable::Allocate(0); 13320 return ObjectHashTable::Allocate(0);
13309 } 13321 }
13310 13322
13311 13323
13312 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) { 13324 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) {
13313 NoHandleAllocation ha; 13325 NoHandleAllocation ha;
13314 ASSERT(args.length() == 2); 13326 ASSERT(args.length() == 2);
13315 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); 13327 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
13316 Object* key = args[1]; 13328 Object* key = args[1];
13329 if (key->IsJSGlobalProxy()) {
13330 key = key->GetPrototype();
13331 if (key->IsNull()) return isolate->heap()->undefined_value();
13332 }
13317 Object* lookup = table->Lookup(key); 13333 Object* lookup = table->Lookup(key);
13318 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup; 13334 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup;
13319 } 13335 }
13320 13336
13321 13337
13322 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) { 13338 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) {
13323 HandleScope scope(isolate); 13339 HandleScope scope(isolate);
13324 ASSERT(args.length() == 3); 13340 ASSERT(args.length() == 3);
13325 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0); 13341 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0);
13326 Handle<Object> key = args.at<Object>(1); 13342 Handle<Object> key = args.at<Object>(1);
13343 if (key->IsJSGlobalProxy()) {
13344 key = handle(key->GetPrototype(), isolate);
13345 if (key->IsNull()) return *table;
13346 }
13327 Handle<Object> value = args.at<Object>(2); 13347 Handle<Object> value = args.at<Object>(2);
13328 return *PutIntoObjectHashTable(table, key, value); 13348 return *PutIntoObjectHashTable(table, key, value);
13329 } 13349 }
13330 13350
13331 13351
13332 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) {
13333 NoHandleAllocation ha;
13334 ASSERT(args.length() == 2);
13335 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
13336 Object* key = args[1];
13337 Object* lookup = table->Lookup(key);
13338 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
13339 }
13340
13341
13342 // ---------------------------------------------------------------------------- 13352 // ----------------------------------------------------------------------------
13343 // Implementation of Runtime 13353 // Implementation of Runtime
13344 13354
13345 #define F(name, number_of_args, result_size) \ 13355 #define F(name, number_of_args, result_size) \
13346 { Runtime::k##name, Runtime::RUNTIME, #name, \ 13356 { Runtime::k##name, Runtime::RUNTIME, #name, \
13347 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size }, 13357 FUNCTION_ADDR(Runtime_##name), number_of_args, result_size },
13348 13358
13349 13359
13350 #define I(name, number_of_args, result_size) \ 13360 #define I(name, number_of_args, result_size) \
13351 { Runtime::kInline##name, Runtime::INLINE, \ 13361 { Runtime::kInline##name, Runtime::INLINE, \
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
13418 // Handle last resort GC and make sure to allow future allocations 13428 // Handle last resort GC and make sure to allow future allocations
13419 // to grow the heap without causing GCs (if possible). 13429 // to grow the heap without causing GCs (if possible).
13420 isolate->counters()->gc_last_resort_from_js()->Increment(); 13430 isolate->counters()->gc_last_resort_from_js()->Increment();
13421 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13431 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13422 "Runtime::PerformGC"); 13432 "Runtime::PerformGC");
13423 } 13433 }
13424 } 13434 }
13425 13435
13426 13436
13427 } } // namespace v8::internal 13437 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | test/cctest/test-object-observe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698