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

Side by Side Diff: src/handles.cc

Issue 8391045: Handlify the remaining CallStubCompiler functions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 // Wrappers for scripts are kept alive and cached in weak global 509 // Wrappers for scripts are kept alive and cached in weak global
510 // handles referred from foreign objects held by the scripts as long as 510 // handles referred from foreign objects held by the scripts as long as
511 // they are used. When they are not used anymore, the garbage 511 // they are used. When they are not used anymore, the garbage
512 // collector will call the weak callback on the global handle 512 // collector will call the weak callback on the global handle
513 // associated with the wrapper and get rid of both the wrapper and the 513 // associated with the wrapper and get rid of both the wrapper and the
514 // handle. 514 // handle.
515 static void ClearWrapperCache(Persistent<v8::Value> handle, void*) { 515 static void ClearWrapperCache(Persistent<v8::Value> handle, void*) {
516 Handle<Object> cache = Utils::OpenHandle(*handle); 516 Handle<Object> cache = Utils::OpenHandle(*handle);
517 JSValue* wrapper = JSValue::cast(*cache); 517 JSValue* wrapper = JSValue::cast(*cache);
518 Foreign* foreign = Script::cast(wrapper->value())->wrapper(); 518 Foreign* foreign = Script::cast(wrapper->value())->wrapper();
519 ASSERT(foreign->address() == reinterpret_cast<Address>(cache.location())); 519 ASSERT(foreign->foreign_address() ==
520 foreign->set_address(0); 520 reinterpret_cast<Address>(cache.location()));
521 foreign->set_foreign_address(0);
521 Isolate* isolate = Isolate::Current(); 522 Isolate* isolate = Isolate::Current();
522 isolate->global_handles()->Destroy(cache.location()); 523 isolate->global_handles()->Destroy(cache.location());
523 isolate->counters()->script_wrappers()->Decrement(); 524 isolate->counters()->script_wrappers()->Decrement();
524 } 525 }
525 526
526 527
527 Handle<JSValue> GetScriptWrapper(Handle<Script> script) { 528 Handle<JSValue> GetScriptWrapper(Handle<Script> script) {
528 if (script->wrapper()->address() != NULL) { 529 if (script->wrapper()->foreign_address() != NULL) {
529 // Return the script wrapper directly from the cache. 530 // Return the script wrapper directly from the cache.
530 return Handle<JSValue>( 531 return Handle<JSValue>(
531 reinterpret_cast<JSValue**>(script->wrapper()->address())); 532 reinterpret_cast<JSValue**>(script->wrapper()->foreign_address()));
532 } 533 }
533 Isolate* isolate = Isolate::Current(); 534 Isolate* isolate = Isolate::Current();
534 // Construct a new script wrapper. 535 // Construct a new script wrapper.
535 isolate->counters()->script_wrappers()->Increment(); 536 isolate->counters()->script_wrappers()->Increment();
536 Handle<JSFunction> constructor = isolate->script_function(); 537 Handle<JSFunction> constructor = isolate->script_function();
537 Handle<JSValue> result = 538 Handle<JSValue> result =
538 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor)); 539 Handle<JSValue>::cast(isolate->factory()->NewJSObject(constructor));
539 result->set_value(*script); 540 result->set_value(*script);
540 541
541 // Create a new weak global handle and use it to cache the wrapper 542 // Create a new weak global handle and use it to cache the wrapper
542 // for future use. The cache will automatically be cleared by the 543 // for future use. The cache will automatically be cleared by the
543 // garbage collector when it is not used anymore. 544 // garbage collector when it is not used anymore.
544 Handle<Object> handle = isolate->global_handles()->Create(*result); 545 Handle<Object> handle = isolate->global_handles()->Create(*result);
545 isolate->global_handles()->MakeWeak(handle.location(), NULL, 546 isolate->global_handles()->MakeWeak(handle.location(), NULL,
546 &ClearWrapperCache); 547 &ClearWrapperCache);
547 script->wrapper()->set_address(reinterpret_cast<Address>(handle.location())); 548 script->wrapper()->set_foreign_address(
549 reinterpret_cast<Address>(handle.location()));
548 return result; 550 return result;
549 } 551 }
550 552
551 553
552 // Init line_ends array with code positions of line ends inside script 554 // Init line_ends array with code positions of line ends inside script
553 // source. 555 // source.
554 void InitScriptLineEnds(Handle<Script> script) { 556 void InitScriptLineEnds(Handle<Script> script) {
555 if (!script->line_ends()->IsUndefined()) return; 557 if (!script->line_ends()->IsUndefined()) return;
556 558
557 Isolate* isolate = script->GetIsolate(); 559 Isolate* isolate = script->GetIsolate();
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table, 912 Handle<ObjectHashTable> PutIntoObjectHashTable(Handle<ObjectHashTable> table,
911 Handle<Object> key, 913 Handle<Object> key,
912 Handle<Object> value) { 914 Handle<Object> value) {
913 CALL_HEAP_FUNCTION(table->GetIsolate(), 915 CALL_HEAP_FUNCTION(table->GetIsolate(),
914 table->Put(*key, *value), 916 table->Put(*key, *value),
915 ObjectHashTable); 917 ObjectHashTable);
916 } 918 }
917 919
918 920
919 } } // namespace v8::internal 921 } } // namespace v8::internal
OLDNEW
« src/arm/stub-cache-arm.cc ('K') | « src/debug.cc ('k') | src/heap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698