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

Side by Side Diff: src/isolate.cc

Issue 16578008: Improved function entry hook coverage (Closed) Base URL: https://chromium.googlesource.com/external/v8.git@post_fix
Patch Set: WIP: Fix X64 implementation. 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
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 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 global_handles_(NULL), 1747 global_handles_(NULL),
1748 context_switcher_(NULL), 1748 context_switcher_(NULL),
1749 thread_manager_(NULL), 1749 thread_manager_(NULL),
1750 fp_stubs_generated_(false), 1750 fp_stubs_generated_(false),
1751 has_installed_extensions_(false), 1751 has_installed_extensions_(false),
1752 string_tracker_(NULL), 1752 string_tracker_(NULL),
1753 regexp_stack_(NULL), 1753 regexp_stack_(NULL),
1754 date_cache_(NULL), 1754 date_cache_(NULL),
1755 code_stub_interface_descriptors_(NULL), 1755 code_stub_interface_descriptors_(NULL),
1756 context_exit_happened_(false), 1756 context_exit_happened_(false),
1757 initialized_from_snapshot_(false),
1757 cpu_profiler_(NULL), 1758 cpu_profiler_(NULL),
1758 heap_profiler_(NULL), 1759 heap_profiler_(NULL),
1760 function_entry_hook_(NullFunctionEntryHook),
1759 deferred_handles_head_(NULL), 1761 deferred_handles_head_(NULL),
1760 optimizing_compiler_thread_(this), 1762 optimizing_compiler_thread_(this),
1761 marking_thread_(NULL), 1763 marking_thread_(NULL),
1762 sweeper_thread_(NULL), 1764 sweeper_thread_(NULL),
1763 callback_table_(NULL) { 1765 callback_table_(NULL) {
1764 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1); 1766 id_ = NoBarrier_AtomicIncrement(&isolate_counter_, 1);
1765 TRACE_ISOLATE(constructor); 1767 TRACE_ISOLATE(constructor);
1766 1768
1767 memset(isolate_addresses_, 0, 1769 memset(isolate_addresses_, 0,
1768 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1)); 1770 sizeof(isolate_addresses_[0]) * (kIsolateAddressCount + 1));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 } 1927 }
1926 1928
1927 1929
1928 void Isolate::SetIsolateThreadLocals(Isolate* isolate, 1930 void Isolate::SetIsolateThreadLocals(Isolate* isolate,
1929 PerIsolateThreadData* data) { 1931 PerIsolateThreadData* data) {
1930 Thread::SetThreadLocal(isolate_key_, isolate); 1932 Thread::SetThreadLocal(isolate_key_, isolate);
1931 Thread::SetThreadLocal(per_isolate_thread_data_key_, data); 1933 Thread::SetThreadLocal(per_isolate_thread_data_key_, data);
1932 } 1934 }
1933 1935
1934 1936
1937 void Isolate::NullFunctionEntryHook(uintptr_t function,
1938 uintptr_t return_addr_location) {
1939 // Ignore callbacks.
1940 }
1941
1942
1943
1935 Isolate::~Isolate() { 1944 Isolate::~Isolate() {
1936 TRACE_ISOLATE(destructor); 1945 TRACE_ISOLATE(destructor);
1937 1946
1938 // Has to be called while counters_ are still alive. 1947 // Has to be called while counters_ are still alive.
1939 runtime_zone_.DeleteKeptSegment(); 1948 runtime_zone_.DeleteKeptSegment();
1940 1949
1941 delete[] assembler_spare_buffer_; 1950 delete[] assembler_spare_buffer_;
1942 assembler_spare_buffer_ = NULL; 1951 assembler_spare_buffer_ = NULL;
1943 1952
1944 delete unicode_cache_; 1953 delete unicode_cache_;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 Release_Store(&debugger_initialized_, true); 2083 Release_Store(&debugger_initialized_, true);
2075 #endif 2084 #endif
2076 } 2085 }
2077 2086
2078 2087
2079 bool Isolate::Init(Deserializer* des) { 2088 bool Isolate::Init(Deserializer* des) {
2080 ASSERT(state_ != INITIALIZED); 2089 ASSERT(state_ != INITIALIZED);
2081 ASSERT(Isolate::Current() == this); 2090 ASSERT(Isolate::Current() == this);
2082 TRACE_ISOLATE(init); 2091 TRACE_ISOLATE(init);
2083 2092
2093 // When function entry hooking is in effect, we have to create the
2094 // code stubs from scratch to get entry hooks, rather than loading the
2095 // previously generated stubs from disk. There need to be guards on
2096 // isolate creation to
2097 if (HasFunctionEntryHook()) {
2098 ASSERT(des == NULL);
2099 }
2100
2084 // The initialization process does not handle memory exhaustion. 2101 // The initialization process does not handle memory exhaustion.
2085 DisallowAllocationFailure disallow_allocation_failure; 2102 DisallowAllocationFailure disallow_allocation_failure;
2086 2103
2087 InitializeLoggingAndCounters(); 2104 InitializeLoggingAndCounters();
2088 2105
2089 InitializeDebugger(); 2106 InitializeDebugger();
2090 2107
2091 memory_allocator_ = new MemoryAllocator(this); 2108 memory_allocator_ = new MemoryAllocator(this);
2092 code_range_ = new CodeRange(this); 2109 code_range_ = new CodeRange(this);
2093 2110
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2144 // SetUp the object heap. 2161 // SetUp the object heap.
2145 ASSERT(!heap_.HasBeenSetUp()); 2162 ASSERT(!heap_.HasBeenSetUp());
2146 if (!heap_.SetUp()) { 2163 if (!heap_.SetUp()) {
2147 V8::FatalProcessOutOfMemory("heap setup"); 2164 V8::FatalProcessOutOfMemory("heap setup");
2148 return false; 2165 return false;
2149 } 2166 }
2150 2167
2151 deoptimizer_data_ = new DeoptimizerData(memory_allocator_); 2168 deoptimizer_data_ = new DeoptimizerData(memory_allocator_);
2152 2169
2153 const bool create_heap_objects = (des == NULL); 2170 const bool create_heap_objects = (des == NULL);
2171
danno 2013/06/13 15:33:44 Stray whitespace change?
Sigurður Ásgeirsson 2013/06/19 20:51:51 Done.
2154 if (create_heap_objects && !heap_.CreateHeapObjects()) { 2172 if (create_heap_objects && !heap_.CreateHeapObjects()) {
2155 V8::FatalProcessOutOfMemory("heap object creation"); 2173 V8::FatalProcessOutOfMemory("heap object creation");
2156 return false; 2174 return false;
2157 } 2175 }
2158 2176
2159 if (create_heap_objects) { 2177 if (create_heap_objects) {
2160 // Terminate the cache array with the sentinel so we can iterate. 2178 // Terminate the cache array with the sentinel so we can iterate.
2161 PushToPartialSnapshotCache(heap_.undefined_value()); 2179 PushToPartialSnapshotCache(heap_.undefined_value());
2162 } 2180 }
2163 2181
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 } 2311 }
2294 } else { 2312 } else {
2295 FLAG_concurrent_sweeping = false; 2313 FLAG_concurrent_sweeping = false;
2296 FLAG_parallel_sweeping = false; 2314 FLAG_parallel_sweeping = false;
2297 } 2315 }
2298 if (FLAG_parallel_recompilation && 2316 if (FLAG_parallel_recompilation &&
2299 SystemThreadManager::NumberOfParallelSystemThreads( 2317 SystemThreadManager::NumberOfParallelSystemThreads(
2300 SystemThreadManager::PARALLEL_RECOMPILATION) == 0) { 2318 SystemThreadManager::PARALLEL_RECOMPILATION) == 0) {
2301 FLAG_parallel_recompilation = false; 2319 FLAG_parallel_recompilation = false;
2302 } 2320 }
2321
2322 initialized_from_snapshot_ = (des != NULL);
2323
2303 return true; 2324 return true;
2304 } 2325 }
2305 2326
2306 2327
2307 // Initialized lazily to allow early 2328 // Initialized lazily to allow early
2308 // v8::V8::SetAddHistogramSampleFunction calls. 2329 // v8::V8::SetAddHistogramSampleFunction calls.
2309 StatsTable* Isolate::stats_table() { 2330 StatsTable* Isolate::stats_table() {
2310 if (stats_table_ == NULL) { 2331 if (stats_table_ == NULL) {
2311 stats_table_ = new StatsTable; 2332 stats_table_ = new StatsTable;
2312 } 2333 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2418 return hstatistics(); 2439 return hstatistics();
2419 } 2440 }
2420 2441
2421 2442
2422 HTracer* Isolate::GetHTracer() { 2443 HTracer* Isolate::GetHTracer() {
2423 if (htracer() == NULL) set_htracer(new HTracer(id())); 2444 if (htracer() == NULL) set_htracer(new HTracer(id()));
2424 return htracer(); 2445 return htracer();
2425 } 2446 }
2426 2447
2427 2448
2449 FunctionEntryHook Isolate::GetFunctionEntryHook() {
2450 if (function_entry_hook_ == NullFunctionEntryHook)
2451 return NULL;
2452
2453 return function_entry_hook_;
2454 }
2455
2456
2457 void Isolate::SetFunctionEntryHook(FunctionEntryHook function_entry_hook) {
2458 if (function_entry_hook == NULL && function_entry_hook_ != NULL) {
danno 2013/06/13 15:33:44 Might it be a little clearer if you can never pass
Sigurður Ásgeirsson 2013/06/19 20:51:51 I made this one-way as we'd discussed. It makes ev
2459 // After an entry hook has once been set on an isolate, the injected entry
2460 // hooking code can't be revoked, and we don't want it calling NULL.
2461 // So instead of NULLing the function, we divert it to a no-op.
2462 function_entry_hook_ = NullFunctionEntryHook;
2463 } else {
2464 function_entry_hook_ = function_entry_hook;
2465 }
2466 }
2467
2468
2428 Map* Isolate::get_initial_js_array_map(ElementsKind kind) { 2469 Map* Isolate::get_initial_js_array_map(ElementsKind kind) {
2429 Context* native_context = context()->native_context(); 2470 Context* native_context = context()->native_context();
2430 Object* maybe_map_array = native_context->js_array_maps(); 2471 Object* maybe_map_array = native_context->js_array_maps();
2431 if (!maybe_map_array->IsUndefined()) { 2472 if (!maybe_map_array->IsUndefined()) {
2432 Object* maybe_transitioned_map = 2473 Object* maybe_transitioned_map =
2433 FixedArray::cast(maybe_map_array)->get(kind); 2474 FixedArray::cast(maybe_map_array)->get(kind);
2434 if (!maybe_transitioned_map->IsUndefined()) { 2475 if (!maybe_transitioned_map->IsUndefined()) {
2435 return Map::cast(maybe_transitioned_map); 2476 return Map::cast(maybe_transitioned_map);
2436 } 2477 }
2437 } 2478 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2471 2512
2472 #ifdef DEBUG 2513 #ifdef DEBUG
2473 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2514 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2474 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2515 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2475 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2516 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2476 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2517 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2477 #undef ISOLATE_FIELD_OFFSET 2518 #undef ISOLATE_FIELD_OFFSET
2478 #endif 2519 #endif
2479 2520
2480 } } // namespace v8::internal 2521 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698