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

Side by Side Diff: src/handles.cc

Issue 16160010: remove old MakeWeak (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 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/global-handles.cc ('k') | src/profile-generator.h » ('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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } 338 }
339 339
340 340
341 // Wrappers for scripts are kept alive and cached in weak global 341 // Wrappers for scripts are kept alive and cached in weak global
342 // handles referred from foreign objects held by the scripts as long as 342 // handles referred from foreign objects held by the scripts as long as
343 // they are used. When they are not used anymore, the garbage 343 // they are used. When they are not used anymore, the garbage
344 // collector will call the weak callback on the global handle 344 // collector will call the weak callback on the global handle
345 // associated with the wrapper and get rid of both the wrapper and the 345 // associated with the wrapper and get rid of both the wrapper and the
346 // handle. 346 // handle.
347 static void ClearWrapperCache(v8::Isolate* v8_isolate, 347 static void ClearWrapperCache(v8::Isolate* v8_isolate,
348 Persistent<v8::Value> handle, 348 Persistent<v8::Value>* handle,
349 void*) { 349 void*) {
350 Handle<Object> cache = Utils::OpenHandle(*handle); 350 Handle<Object> cache = Utils::OpenHandle(**handle);
351 JSValue* wrapper = JSValue::cast(*cache); 351 JSValue* wrapper = JSValue::cast(*cache);
352 Foreign* foreign = Script::cast(wrapper->value())->wrapper(); 352 Foreign* foreign = Script::cast(wrapper->value())->wrapper();
353 ASSERT(foreign->foreign_address() == 353 ASSERT(foreign->foreign_address() ==
354 reinterpret_cast<Address>(cache.location())); 354 reinterpret_cast<Address>(cache.location()));
355 foreign->set_foreign_address(0); 355 foreign->set_foreign_address(0);
356 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 356 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate);
357 isolate->global_handles()->Destroy(cache.location()); 357 isolate->global_handles()->Destroy(cache.location());
358 isolate->counters()->script_wrappers()->Decrement(); 358 isolate->counters()->script_wrappers()->Decrement();
359 } 359 }
360 360
(...skipping 20 matching lines...) Expand all
381 } 381 }
382 382
383 result->set_value(*script); 383 result->set_value(*script);
384 384
385 // Create a new weak global handle and use it to cache the wrapper 385 // Create a new weak global handle and use it to cache the wrapper
386 // for future use. The cache will automatically be cleared by the 386 // for future use. The cache will automatically be cleared by the
387 // garbage collector when it is not used anymore. 387 // garbage collector when it is not used anymore.
388 Handle<Object> handle = isolate->global_handles()->Create(*result); 388 Handle<Object> handle = isolate->global_handles()->Create(*result);
389 isolate->global_handles()->MakeWeak(handle.location(), 389 isolate->global_handles()->MakeWeak(handle.location(),
390 NULL, 390 NULL,
391 NULL,
392 &ClearWrapperCache); 391 &ClearWrapperCache);
393 script->wrapper()->set_foreign_address( 392 script->wrapper()->set_foreign_address(
394 reinterpret_cast<Address>(handle.location())); 393 reinterpret_cast<Address>(handle.location()));
395 return result; 394 return result;
396 } 395 }
397 396
398 397
399 // Init line_ends array with code positions of line ends inside script 398 // Init line_ends array with code positions of line ends inside script
400 // source. 399 // source.
401 void InitScriptLineEnds(Handle<Script> script) { 400 void InitScriptLineEnds(Handle<Script> script) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 data->next = prev_next_; 922 data->next = prev_next_;
924 data->limit = prev_limit_; 923 data->limit = prev_limit_;
925 #ifdef DEBUG 924 #ifdef DEBUG
926 handles_detached_ = true; 925 handles_detached_ = true;
927 #endif 926 #endif
928 return deferred; 927 return deferred;
929 } 928 }
930 929
931 930
932 } } // namespace v8::internal 931 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | src/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698