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

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: Created 8 years, 1 month 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 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
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()->undefined_value();
rossberg 2012/11/21 12:43:17 Perhaps you should return false here.
adamk 2012/11/21 17:02:57 Ah, that's probably a better plan, yes.
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 JSGlobalProxy* global_proxy = NULL;
rossberg 2012/11/21 12:43:17 What do you need this for?
adamk 2012/11/21 17:02:57 Cruft from a previous version before I discovered
13176 if (obj->IsJSGlobalProxy()) {
13177 Object* proto = obj->GetPrototype();
13178 if (obj->IsNull()) return isolate->heap()->undefined_value();
13179 ASSERT(proto->IsJSGlobalObject());
13180 global_proxy = JSGlobalProxy::cast(obj);
13181 obj = JSReceiver::cast(proto);
13182 }
13169 if (obj->map()->is_observed() != is_observed) { 13183 if (obj->map()->is_observed() != is_observed) {
13170 MaybeObject* maybe = obj->map()->Copy(); 13184 MaybeObject* maybe = obj->map()->Copy();
13171 Map* map; 13185 Map* map;
13172 if (!maybe->To(&map)) return maybe; 13186 if (!maybe->To(&map)) return maybe;
13173 map->set_is_observed(is_observed); 13187 map->set_is_observed(is_observed);
13174 obj->set_map(map); 13188 obj->set_map(map);
13175 } 13189 }
13176 return isolate->heap()->undefined_value(); 13190 return isolate->heap()->undefined_value();
13177 } 13191 }
13178 13192
(...skipping 15 matching lines...) Expand all
13194 ASSERT(args.length() == 0); 13208 ASSERT(args.length() == 0);
13195 return ObjectHashTable::Allocate(0); 13209 return ObjectHashTable::Allocate(0);
13196 } 13210 }
13197 13211
13198 13212
13199 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) { 13213 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableGet) {
13200 NoHandleAllocation ha; 13214 NoHandleAllocation ha;
13201 ASSERT(args.length() == 2); 13215 ASSERT(args.length() == 2);
13202 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); 13216 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
13203 Object* key = args[1]; 13217 Object* key = args[1];
13218 if (key->IsJSGlobalProxy()) {
13219 key = key->GetPrototype();
13220 if (key->IsNull()) return isolate->heap()->undefined_value();
13221 }
13204 Object* lookup = table->Lookup(key); 13222 Object* lookup = table->Lookup(key);
13205 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup; 13223 return lookup->IsTheHole() ? isolate->heap()->undefined_value() : lookup;
13206 } 13224 }
13207 13225
13208 13226
13209 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) { 13227 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableSet) {
13210 HandleScope scope(isolate); 13228 HandleScope scope(isolate);
13211 ASSERT(args.length() == 3); 13229 ASSERT(args.length() == 3);
13212 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0); 13230 CONVERT_ARG_HANDLE_CHECKED(ObjectHashTable, table, 0);
13213 Handle<Object> key = args.at<Object>(1); 13231 Handle<Object> key = args.at<Object>(1);
13232 if (key->IsJSGlobalProxy()) {
13233 key = handle(key->GetPrototype(), isolate);
13234 if (key->IsNull()) return isolate->heap()->undefined_value();
rossberg 2012/11/21 12:43:17 Return this.
adamk 2012/11/21 17:02:57 Woops, fixed. This is one that will be covered by
13235 }
13214 Handle<Object> value = args.at<Object>(2); 13236 Handle<Object> value = args.at<Object>(2);
13215 return *PutIntoObjectHashTable(table, key, value); 13237 return *PutIntoObjectHashTable(table, key, value);
13216 } 13238 }
13217 13239
13218 13240
13219 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) { 13241 RUNTIME_FUNCTION(MaybeObject*, Runtime_ObjectHashTableHas) {
13220 NoHandleAllocation ha; 13242 NoHandleAllocation ha;
13221 ASSERT(args.length() == 2); 13243 ASSERT(args.length() == 2);
13222 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0); 13244 CONVERT_ARG_CHECKED(ObjectHashTable, table, 0);
13223 Object* key = args[1]; 13245 Object* key = args[1];
13246 if (key->IsJSGlobalProxy()) {
13247 key = key->GetPrototype();
13248 if (key->IsNull()) return isolate->heap()->undefined_value();
rossberg 2012/11/21 12:43:17 False here, too.
adamk 2012/11/21 17:02:57 This function wasn't carrying its weight, just rem
rossberg 2012/11/22 12:17:05 I'm fine with that. But note that there no longer
13249 }
13224 Object* lookup = table->Lookup(key); 13250 Object* lookup = table->Lookup(key);
13225 return isolate->heap()->ToBoolean(!lookup->IsTheHole()); 13251 return isolate->heap()->ToBoolean(!lookup->IsTheHole());
13226 } 13252 }
13227 13253
13228 13254
13229 // ---------------------------------------------------------------------------- 13255 // ----------------------------------------------------------------------------
13230 // Implementation of Runtime 13256 // Implementation of Runtime
13231 13257
13232 #define F(name, number_of_args, result_size) \ 13258 #define F(name, number_of_args, result_size) \
13233 { Runtime::k##name, Runtime::RUNTIME, #name, \ 13259 { Runtime::k##name, Runtime::RUNTIME, #name, \
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
13305 // Handle last resort GC and make sure to allow future allocations 13331 // Handle last resort GC and make sure to allow future allocations
13306 // to grow the heap without causing GCs (if possible). 13332 // to grow the heap without causing GCs (if possible).
13307 isolate->counters()->gc_last_resort_from_js()->Increment(); 13333 isolate->counters()->gc_last_resort_from_js()->Increment();
13308 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 13334 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
13309 "Runtime::PerformGC"); 13335 "Runtime::PerformGC");
13310 } 13336 }
13311 } 13337 }
13312 13338
13313 13339
13314 } } // namespace v8::internal 13340 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698