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

Side by Side Diff: src/handles.cc

Issue 99193002: Remove all stuff marked as V8_DEPRECATED. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebased. Created 7 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/global-handles.cc ('k') | src/i18n.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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object); 218 isolate->heap()->LookupSingleCharacterStringFromCode(index), Object);
219 } 219 }
220 220
221 221
222 // Wrappers for scripts are kept alive and cached in weak global 222 // Wrappers for scripts are kept alive and cached in weak global
223 // handles referred from foreign objects held by the scripts as long as 223 // handles referred from foreign objects held by the scripts as long as
224 // they are used. When they are not used anymore, the garbage 224 // they are used. When they are not used anymore, the garbage
225 // collector will call the weak callback on the global handle 225 // collector will call the weak callback on the global handle
226 // associated with the wrapper and get rid of both the wrapper and the 226 // associated with the wrapper and get rid of both the wrapper and the
227 // handle. 227 // handle.
228 static void ClearWrapperCache(v8::Isolate* v8_isolate, 228 static void ClearWrapperCache(
229 Persistent<v8::Value>* handle, 229 const v8::WeakCallbackData<v8::Value, void>& data) {
230 void*) { 230 Object** location = reinterpret_cast<Object**>(data.GetParameter());
231 Handle<Object> cache = Utils::OpenPersistent(handle); 231 JSValue* wrapper = JSValue::cast(*location);
232 JSValue* wrapper = JSValue::cast(*cache);
233 Foreign* foreign = Script::cast(wrapper->value())->wrapper(); 232 Foreign* foreign = Script::cast(wrapper->value())->wrapper();
234 ASSERT(foreign->foreign_address() == 233 ASSERT_EQ(foreign->foreign_address(), reinterpret_cast<Address>(location));
235 reinterpret_cast<Address>(cache.location()));
236 foreign->set_foreign_address(0); 234 foreign->set_foreign_address(0);
237 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 235 GlobalHandles::Destroy(location);
238 isolate->global_handles()->Destroy(cache.location()); 236 Isolate* isolate = reinterpret_cast<Isolate*>(data.GetIsolate());
239 isolate->counters()->script_wrappers()->Decrement(); 237 isolate->counters()->script_wrappers()->Decrement();
240 } 238 }
241 239
242 240
243 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { 241 Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
244 if (script->wrapper()->foreign_address() != NULL) { 242 if (script->wrapper()->foreign_address() != NULL) {
245 // Return a handle for the existing script wrapper from the cache. 243 // Return a handle for the existing script wrapper from the cache.
246 return Handle<JSValue>( 244 return Handle<JSValue>(
247 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); 245 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address()));
248 } 246 }
(...skipping 11 matching lines...) Expand all
260 return Handle<JSValue>( 258 return Handle<JSValue>(
261 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address())); 259 *reinterpret_cast<JSValue**>(script->wrapper()->foreign_address()));
262 } 260 }
263 261
264 result->set_value(*script); 262 result->set_value(*script);
265 263
266 // Create a new weak global handle and use it to cache the wrapper 264 // Create a new weak global handle and use it to cache the wrapper
267 // for future use. The cache will automatically be cleared by the 265 // for future use. The cache will automatically be cleared by the
268 // garbage collector when it is not used anymore. 266 // garbage collector when it is not used anymore.
269 Handle<Object> handle = isolate->global_handles()->Create(*result); 267 Handle<Object> handle = isolate->global_handles()->Create(*result);
270 isolate->global_handles()->MakeWeak(handle.location(), 268 GlobalHandles::MakeWeak(handle.location(),
271 NULL, 269 reinterpret_cast<void*>(handle.location()),
272 &ClearWrapperCache); 270 &ClearWrapperCache);
273 script->wrapper()->set_foreign_address( 271 script->wrapper()->set_foreign_address(
274 reinterpret_cast<Address>(handle.location())); 272 reinterpret_cast<Address>(handle.location()));
275 return result; 273 return result;
276 } 274 }
277 275
278 276
279 // Init line_ends array with code positions of line ends inside script 277 // Init line_ends array with code positions of line ends inside script
280 // source. 278 // source.
281 void InitScriptLineEnds(Handle<Script> script) { 279 void InitScriptLineEnds(Handle<Script> script) {
282 if (!script->line_ends()->IsUndefined()) return; 280 if (!script->line_ends()->IsUndefined()) return;
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 Handle<Code> code) { 793 Handle<Code> code) {
796 heap->EnsureWeakObjectToCodeTable(); 794 heap->EnsureWeakObjectToCodeTable();
797 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object)); 795 Handle<DependentCode> dep(heap->LookupWeakObjectToCodeDependency(*object));
798 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code); 796 dep = DependentCode::Insert(dep, DependentCode::kWeaklyEmbeddedGroup, code);
799 CALL_HEAP_FUNCTION_VOID(heap->isolate(), 797 CALL_HEAP_FUNCTION_VOID(heap->isolate(),
800 heap->AddWeakObjectToCodeDependency(*object, *dep)); 798 heap->AddWeakObjectToCodeDependency(*object, *dep));
801 } 799 }
802 800
803 801
804 } } // namespace v8::internal 802 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/global-handles.cc ('k') | src/i18n.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698