| OLD | NEW |
| 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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 } | 536 } |
| 537 | 537 |
| 538 | 538 |
| 539 // Wrappers for scripts are kept alive and cached in weak global | 539 // Wrappers for scripts are kept alive and cached in weak global |
| 540 // handles referred from foreign objects held by the scripts as long as | 540 // handles referred from foreign objects held by the scripts as long as |
| 541 // they are used. When they are not used anymore, the garbage | 541 // they are used. When they are not used anymore, the garbage |
| 542 // collector will call the weak callback on the global handle | 542 // collector will call the weak callback on the global handle |
| 543 // associated with the wrapper and get rid of both the wrapper and the | 543 // associated with the wrapper and get rid of both the wrapper and the |
| 544 // handle. | 544 // handle. |
| 545 static void ClearWrapperCache(Persistent<v8::Value> handle, void*) { | 545 static void ClearWrapperCache(Persistent<v8::Value> handle, void*) { |
| 546 #ifdef ENABLE_HEAP_PROTECTION | |
| 547 // Weak reference callbacks are called as if from outside V8. We | |
| 548 // need to reeenter to unprotect the heap. | |
| 549 VMState state(OTHER); | |
| 550 #endif | |
| 551 Handle<Object> cache = Utils::OpenHandle(*handle); | 546 Handle<Object> cache = Utils::OpenHandle(*handle); |
| 552 JSValue* wrapper = JSValue::cast(*cache); | 547 JSValue* wrapper = JSValue::cast(*cache); |
| 553 Foreign* foreign = Script::cast(wrapper->value())->wrapper(); | 548 Foreign* foreign = Script::cast(wrapper->value())->wrapper(); |
| 554 ASSERT(foreign->address() == reinterpret_cast<Address>(cache.location())); | 549 ASSERT(foreign->address() == reinterpret_cast<Address>(cache.location())); |
| 555 foreign->set_address(0); | 550 foreign->set_address(0); |
| 556 Isolate* isolate = Isolate::Current(); | 551 Isolate* isolate = Isolate::Current(); |
| 557 isolate->global_handles()->Destroy(cache.location()); | 552 isolate->global_handles()->Destroy(cache.location()); |
| 558 isolate->counters()->script_wrappers()->Decrement(); | 553 isolate->counters()->script_wrappers()->Decrement(); |
| 559 } | 554 } |
| 560 | 555 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 | 966 |
| 972 bool CompileOptimized(Handle<JSFunction> function, | 967 bool CompileOptimized(Handle<JSFunction> function, |
| 973 int osr_ast_id, | 968 int osr_ast_id, |
| 974 ClearExceptionFlag flag) { | 969 ClearExceptionFlag flag) { |
| 975 CompilationInfo info(function); | 970 CompilationInfo info(function); |
| 976 info.SetOptimizing(osr_ast_id); | 971 info.SetOptimizing(osr_ast_id); |
| 977 return CompileLazyHelper(&info, flag); | 972 return CompileLazyHelper(&info, flag); |
| 978 } | 973 } |
| 979 | 974 |
| 980 } } // namespace v8::internal | 975 } } // namespace v8::internal |
| OLD | NEW |