| OLD | NEW |
| 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::OpenPersistent(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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 #endif | 592 #endif |
| 593 } | 593 } |
| 594 } | 594 } |
| 595 return v8::Local<v8::Array>::New(reinterpret_cast<v8::Isolate*>(isolate), | 595 return v8::Local<v8::Array>::New(reinterpret_cast<v8::Isolate*>(isolate), |
| 596 result); | 596 result); |
| 597 } | 597 } |
| 598 | 598 |
| 599 | 599 |
| 600 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { | 600 Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) { |
| 601 Isolate* isolate = script->GetIsolate(); | 601 Isolate* isolate = script->GetIsolate(); |
| 602 if (!isolate->IsInitialized()) { | |
| 603 return isolate->factory()->undefined_value(); | |
| 604 } | |
| 605 Handle<String> name_or_source_url_key = | 602 Handle<String> name_or_source_url_key = |
| 606 isolate->factory()->InternalizeOneByteString( | 603 isolate->factory()->InternalizeOneByteString( |
| 607 STATIC_ASCII_VECTOR("nameOrSourceURL")); | 604 STATIC_ASCII_VECTOR("nameOrSourceURL")); |
| 608 Handle<JSValue> script_wrapper = GetScriptWrapper(script); | 605 Handle<JSValue> script_wrapper = GetScriptWrapper(script); |
| 609 Handle<Object> property = GetProperty(isolate, | 606 Handle<Object> property = GetProperty(isolate, |
| 610 script_wrapper, | 607 script_wrapper, |
| 611 name_or_source_url_key); | 608 name_or_source_url_key); |
| 612 ASSERT(property->IsJSFunction()); | 609 ASSERT(property->IsJSFunction()); |
| 613 Handle<JSFunction> method = Handle<JSFunction>::cast(property); | 610 Handle<JSFunction> method = Handle<JSFunction>::cast(property); |
| 614 bool caught_exception; | 611 bool caught_exception; |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 data->next = prev_next_; | 924 data->next = prev_next_; |
| 928 data->limit = prev_limit_; | 925 data->limit = prev_limit_; |
| 929 #ifdef DEBUG | 926 #ifdef DEBUG |
| 930 handles_detached_ = true; | 927 handles_detached_ = true; |
| 931 #endif | 928 #endif |
| 932 return deferred; | 929 return deferred; |
| 933 } | 930 } |
| 934 | 931 |
| 935 | 932 |
| 936 } } // namespace v8::internal | 933 } } // namespace v8::internal |
| OLD | NEW |