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

Side by Side Diff: src/v8.cc

Issue 10706002: Implements a new API to set a function entry hook for profiling. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Sketch ARM code stub. Created 8 years, 5 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 | Annotate | Revision Log
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 bool V8::has_been_set_up_ = false; 53 bool V8::has_been_set_up_ = false;
54 bool V8::has_been_disposed_ = false; 54 bool V8::has_been_disposed_ = false;
55 bool V8::has_fatal_error_ = false; 55 bool V8::has_fatal_error_ = false;
56 bool V8::use_crankshaft_ = true; 56 bool V8::use_crankshaft_ = true;
57 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL; 57 List<CallCompletedCallback>* V8::call_completed_callbacks_ = NULL;
58 58
59 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER; 59 static LazyMutex entropy_mutex = LAZY_MUTEX_INITIALIZER;
60 60
61 static EntropySource entropy_source; 61 static EntropySource entropy_source;
62 62
63 static FunctionEntryHook profiler_entry_hook = NULL;
64
63 65
64 bool V8::Initialize(Deserializer* des) { 66 bool V8::Initialize(Deserializer* des) {
65 FlagList::EnforceFlagImplications(); 67 FlagList::EnforceFlagImplications();
66 68
67 InitializeOncePerProcess(); 69 InitializeOncePerProcess();
68 70
69 // The current thread may not yet had entered an isolate to run. 71 // The current thread may not yet had entered an isolate to run.
70 // Note the Isolate::Current() may be non-null because for various 72 // Note the Isolate::Current() may be non-null because for various
71 // initialization purposes an initializing thread may be assigned an isolate 73 // initialization purposes an initializing thread may be assigned an isolate
72 // but not actually enter it. 74 // but not actually enter it.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 entropy_source = source; 159 entropy_source = source;
158 } 160 }
159 161
160 162
161 void V8::SetReturnAddressLocationResolver( 163 void V8::SetReturnAddressLocationResolver(
162 ReturnAddressLocationResolver resolver) { 164 ReturnAddressLocationResolver resolver) {
163 StackFrame::SetReturnAddressLocationResolver(resolver); 165 StackFrame::SetReturnAddressLocationResolver(resolver);
164 } 166 }
165 167
166 168
169 bool V8::SetFunctionEntryHook(FunctionEntryHook entry_hook) {
170 // We don't allow setting a new entry hook over one that's
171 // already active, as the hooks won't stack.
172 if (entry_hook != 0 && profiler_entry_hook != 0)
173 return false;
174
175 profiler_entry_hook = entry_hook;
176
177 return true;
178 }
179
180
181 static void EntryHookDispatcher(intptr_t function,
182 intptr_t stack_pointer,
183 uint64_t entry_time) {
184 if (profiler_entry_hook != NULL)
185 profiler_entry_hook(function, stack_pointer, entry_time);
danno 2012/07/10 09:37:13 80 col?
Sigurður Ásgeirsson 2012/07/11 14:50:34 Done.
186 }
187
188
189
190 const FunctionEntryHook* V8::GetFunctionEntryHookLocation() {
191 return &profiler_entry_hook;
192 }
193
194
195 FunctionEntryHook V8::GetFunctionEntryHookDispatcher() {
196 return EntryHookDispatcher;
197 }
198
199
167 // Used by JavaScript APIs 200 // Used by JavaScript APIs
168 uint32_t V8::Random(Context* context) { 201 uint32_t V8::Random(Context* context) {
169 ASSERT(context->IsGlobalContext()); 202 ASSERT(context->IsGlobalContext());
170 ByteArray* seed = context->random_seed(); 203 ByteArray* seed = context->random_seed();
171 return random_base(reinterpret_cast<uint32_t*>(seed->GetDataStartAddress())); 204 return random_base(reinterpret_cast<uint32_t*>(seed->GetDataStartAddress()));
172 } 205 }
173 206
174 207
175 // Used internally by the JIT and memory allocator for security 208 // Used internally by the JIT and memory allocator for security
176 // purposes. So, we keep a different state to prevent informations 209 // purposes. So, we keep a different state to prevent informations
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 SetUpJSCallerSavedCodeData(); 312 SetUpJSCallerSavedCodeData();
280 SamplerRegistry::SetUp(); 313 SamplerRegistry::SetUp();
281 ExternalReference::SetUp(); 314 ExternalReference::SetUp();
282 } 315 }
283 316
284 void V8::InitializeOncePerProcess() { 317 void V8::InitializeOncePerProcess() {
285 CallOnce(&init_once, &InitializeOncePerProcessImpl); 318 CallOnce(&init_once, &InitializeOncePerProcessImpl);
286 } 319 }
287 320
288 } } // namespace v8::internal 321 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698