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

Side by Side Diff: include/v8.h

Issue 519543002: [WIP] Added CodeEventListener to the sampler API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CallbackEvent also logs as code-creation, added coverage for that. Created 6 years, 3 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
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** \mainpage V8 API Reference Guide 5 /** \mainpage V8 API Reference Guide
6 * 6 *
7 * V8 is Google's open source JavaScript engine. 7 * V8 is Google's open source JavaScript engine.
8 * 8 *
9 * This set of documents provides reference material generated from the 9 * This set of documents provides reference material generated from the
10 * V8 header file, include/v8.h. 10 * V8 header file, include/v8.h.
11 * 11 *
12 * For other documentation see http://code.google.com/apis/v8/ 12 * For other documentation see http://code.google.com/apis/v8/
13 */ 13 */
14 14
15 #ifndef V8_H_ 15 #ifndef V8_H_
16 #define V8_H_ 16 #define V8_H_
17 17
18 #include <string>
19
18 #include "v8stdint.h" 20 #include "v8stdint.h"
19 21
20 // We reserve the V8_* prefix for macros defined in V8 public API and 22 // We reserve the V8_* prefix for macros defined in V8 public API and
21 // assume there are no name conflicts with the embedder's code. 23 // assume there are no name conflicts with the embedder's code.
22 24
23 #ifdef V8_OS_WIN 25 #ifdef V8_OS_WIN
24 26
25 // Setup for Windows DLL export/import. When building the V8 DLL the 27 // Setup for Windows DLL export/import. When building the V8 DLL the
26 // BUILDING_V8_SHARED needs to be defined. When building a program which uses 28 // BUILDING_V8_SHARED needs to be defined. When building a program which uses
27 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 29 // the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8
(...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 bool IsEval() const; 1292 bool IsEval() const;
1291 1293
1292 /** 1294 /**
1293 * Returns whether or not the associated function is called as a 1295 * Returns whether or not the associated function is called as a
1294 * constructor via "new". 1296 * constructor via "new".
1295 */ 1297 */
1296 bool IsConstructor() const; 1298 bool IsConstructor() const;
1297 }; 1299 };
1298 1300
1299 1301
1302 // --- Sampler API ---
1303
1304
1305 /* TODO(gholap): This should go away and struct Sample should
1306 just use const void* instead of Address.
1307 Currently we need it because of implementation details. */
1308 typedef unsigned char* Address;
1309
1310
1311 /**
1312 * Isolate::Getsample collects the current JS execution state as a sample.
1313 * A collected sample contains,
1314 * - stack : An array of addresses.
1315 * One address per stack frame.
1316 * The address is the instruction pointer,
1317 * pointing to the instruction which led to the
1318 * creation of the stack frame.
1319 * (for example, a function call)
1320 * - frames_count: Number of stack frames that were captured.
1321 * That is, stack[frames_count+i] might contain meaningless
1322 * addresses for any i >= 0.
1323 */
1324 struct V8_EXPORT Sample {
1325 Sample()
1326 : frames_count(0) {}
1327 static const unsigned kMaxFramesCount = 255;
1328
1329 Address stack[kMaxFramesCount]; // Call stack.
1330 unsigned frames_count; // Number of captured frames.
1331 };
1332
1333
1334 /**
1335 * To make sense of the PC values gotten from each sample,
1336 * information like the location of compiled code for functions,
1337 * whether the code ever moved from that address etc is required.
1338 *
1339 * Whenever v8 creates/moves/deletes code, or links a shared library,
1340 * this handler will be called to notify of the code event.
1341 */
1342 class V8_EXPORT CodeEventHandler {
1343 public:
1344 virtual ~CodeEventHandler() {}
1345
1346 /**
1347 * Called when code is created.
1348 * @from: The address where this newly created code begins.
1349 * @size: Size of the code.
1350 * @name: String representing the name of the code.
1351 */
1352 virtual void Create(const void* from,
1353 const int size,
1354 const std::string& name) = 0;
1355
1356 /**
1357 * Called when code is deleted.
1358 * @from: The address from where the code was deleted.
1359 */
1360 virtual void Delete(const void* from) = 0;
1361
1362 /**
1363 * Called when code is moved.
1364 * @from: The initial address where code was.
1365 * @to: New address where the code currently resides.
1366 */
1367 virtual void Move(const void* from, const void* to) = 0;
1368
1369 /**
1370 * Called when v8 loads a shared library.
1371 * @library_path: Path to the shared library as a string.
1372 * @start: The shared library is loaded into memory starting at this address.
1373 * @end: Code beyond this address doesn't belong to the shared library.
1374 */
1375 virtual void SharedLibrary(const std::string& library_path,
1376 const void* start,
1377 const void* end) = 0;
1378 };
1379
1380
1300 /** 1381 /**
1301 * A JSON Parser. 1382 * A JSON Parser.
1302 */ 1383 */
1303 class V8_EXPORT JSON { 1384 class V8_EXPORT JSON {
1304 public: 1385 public:
1305 /** 1386 /**
1306 * Tries to parse the string |json_string| and returns it as value if 1387 * Tries to parse the string |json_string| and returns it as value if
1307 * successful. 1388 * successful.
1308 * 1389 *
1309 * \param json_string The string to parse. 1390 * \param json_string The string to parse.
(...skipping 2900 matching lines...) Expand 10 before | Expand all | Expand 10 after
4210 * are in the range of 0 - GetNumberOfDataSlots() - 1. 4291 * are in the range of 0 - GetNumberOfDataSlots() - 1.
4211 */ 4292 */
4212 V8_INLINE static uint32_t GetNumberOfDataSlots(); 4293 V8_INLINE static uint32_t GetNumberOfDataSlots();
4213 4294
4214 /** 4295 /**
4215 * Get statistics about the heap memory usage. 4296 * Get statistics about the heap memory usage.
4216 */ 4297 */
4217 void GetHeapStatistics(HeapStatistics* heap_statistics); 4298 void GetHeapStatistics(HeapStatistics* heap_statistics);
4218 4299
4219 /** 4300 /**
4301 * Get a sample from the isolate.
4302 */
4303 void GetSample(Sample* sample);
4304
4305 /**
4306 * Install the handler which listens to code creation/move/delete events
4307 * which are needed to eventually make sense of PC values inside a sample.
4308 */
4309 void InstallCodeEventHandler(CodeEventHandler* handler);
4310
4311 /**
4220 * Adjusts the amount of registered external memory. Used to give V8 an 4312 * Adjusts the amount of registered external memory. Used to give V8 an
4221 * indication of the amount of externally allocated memory that is kept alive 4313 * indication of the amount of externally allocated memory that is kept alive
4222 * by JavaScript objects. V8 uses this to decide when to perform global 4314 * by JavaScript objects. V8 uses this to decide when to perform global
4223 * garbage collections. Registering externally allocated memory will trigger 4315 * garbage collections. Registering externally allocated memory will trigger
4224 * global garbage collections more often than it would otherwise in an attempt 4316 * global garbage collections more often than it would otherwise in an attempt
4225 * to garbage collect the JavaScript objects that keep the externally 4317 * to garbage collect the JavaScript objects that keep the externally
4226 * allocated memory alive. 4318 * allocated memory alive.
4227 * 4319 *
4228 * \param change_in_bytes the change in externally allocated memory that is 4320 * \param change_in_bytes the change in externally allocated memory that is
4229 * kept alive by JavaScript objects. 4321 * kept alive by JavaScript objects.
(...skipping 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6703 */ 6795 */
6704 6796
6705 6797
6706 } // namespace v8 6798 } // namespace v8
6707 6799
6708 6800
6709 #undef TYPE_CHECK 6801 #undef TYPE_CHECK
6710 6802
6711 6803
6712 #endif // V8_H_ 6804 #endif // V8_H_
OLDNEW
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698