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

Side by Side Diff: src/debug/liveedit.h

Issue 2169833002: [parser] Refactor AstTraversalVisitor (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 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
« no previous file with comments | « src/ast/ast-traversal-visitor.h ('k') | src/debug/liveedit.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 #ifndef V8_DEBUG_LIVEEDIT_H_ 5 #ifndef V8_DEBUG_LIVEEDIT_H_
6 #define V8_DEBUG_LIVEEDIT_H_ 6 #define V8_DEBUG_LIVEEDIT_H_
7 7
8 8
9 // Live Edit feature implementation. 9 // Live Edit feature implementation.
10 // User should be able to change script on already running VM. This feature 10 // User should be able to change script on already running VM. This feature
11 // matches hot swap features in other frameworks. 11 // matches hot swap features in other frameworks.
12 // 12 //
13 // The basic use-case is when user spots some mistake in function body 13 // The basic use-case is when user spots some mistake in function body
14 // from debugger and wishes to change the algorithm without restart. 14 // from debugger and wishes to change the algorithm without restart.
15 // 15 //
16 // A single change always has a form of a simple replacement (in pseudo-code): 16 // A single change always has a form of a simple replacement (in pseudo-code):
17 // script.source[positions, positions+length] = new_string; 17 // script.source[positions, positions+length] = new_string;
18 // Implementation first determines, which function's body includes this 18 // Implementation first determines, which function's body includes this
19 // change area. Then both old and new versions of script are fully compiled 19 // change area. Then both old and new versions of script are fully compiled
20 // in order to analyze, whether the function changed its outer scope 20 // in order to analyze, whether the function changed its outer scope
21 // expectations (or number of parameters). If it didn't, function's code is 21 // expectations (or number of parameters). If it didn't, function's code is
22 // patched with a newly compiled code. If it did change, enclosing function 22 // patched with a newly compiled code. If it did change, enclosing function
23 // gets patched. All inner functions are left untouched, whatever happened 23 // gets patched. All inner functions are left untouched, whatever happened
24 // to them in a new script version. However, new version of code will 24 // to them in a new script version. However, new version of code will
25 // instantiate newly compiled functions. 25 // instantiate newly compiled functions.
26 26
27 27
28 #include "src/allocation.h" 28 #include "src/allocation.h"
29 #include "src/ast/ast-traversal-visitor.h"
29 #include "src/compiler.h" 30 #include "src/compiler.h"
30 31
31 namespace v8 { 32 namespace v8 {
32 namespace internal { 33 namespace internal {
33 34
34 // This class collects some specific information on structure of functions 35 // This class collects some specific information on structure of functions
35 // in a particular script. 36 // in a particular script.
36 // 37 //
37 // The primary interest of the Tracker is to record function scope structures 38 // The primary interest of the Tracker is to record function scope structures
38 // in order to analyze whether function code may be safely patched (with new 39 // in order to analyze whether function code may be safely patched (with new
39 // code successfully reading existing data from function scopes). The Tracker 40 // code successfully reading existing data from function scopes). The Tracker
40 // also collects compiled function codes. 41 // also collects compiled function codes.
41 class LiveEditFunctionTracker : public AstTraversalVisitor { 42 class LiveEditFunctionTracker
43 : public AstTraversalVisitor<LiveEditFunctionTracker> {
42 public: 44 public:
43 // Traverses the entire AST, and records information about all 45 // Traverses the entire AST, and records information about all
44 // FunctionLiterals for further use by LiveEdit code patching. The collected 46 // FunctionLiterals for further use by LiveEdit code patching. The collected
45 // information is returned as a serialized array. 47 // information is returned as a serialized array.
46 static Handle<JSArray> Collect(FunctionLiteral* node, Handle<Script> script, 48 static Handle<JSArray> Collect(FunctionLiteral* node, Handle<Script> script,
47 Zone* zone, Isolate* isolate); 49 Zone* zone, Isolate* isolate);
48 50
49 virtual ~LiveEditFunctionTracker() {} 51 protected:
50 void VisitFunctionLiteral(FunctionLiteral* node) override; 52 friend AstTraversalVisitor<LiveEditFunctionTracker>;
53 void VisitFunctionLiteral(FunctionLiteral* node);
51 54
52 private: 55 private:
53 LiveEditFunctionTracker(Handle<Script> script, Zone* zone, Isolate* isolate); 56 LiveEditFunctionTracker(Handle<Script> script, Zone* zone, Isolate* isolate);
54 57
55 void FunctionStarted(FunctionLiteral* fun); 58 void FunctionStarted(FunctionLiteral* fun);
56 void FunctionDone(Handle<SharedFunctionInfo> shared, Scope* scope); 59 void FunctionDone(Handle<SharedFunctionInfo> shared, Scope* scope);
57 Handle<Object> SerializeFunctionScope(Scope* scope); 60 Handle<Object> SerializeFunctionScope(Scope* scope);
58 61
59 Handle<Script> script_; 62 Handle<Script> script_;
60 Zone* zone_; 63 Zone* zone_;
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 static const int kSharedInfoOffset_ = 3; 373 static const int kSharedInfoOffset_ = 3;
371 static const int kSize_ = 4; 374 static const int kSize_ = 4;
372 375
373 friend class JSArrayBasedStruct<SharedInfoWrapper>; 376 friend class JSArrayBasedStruct<SharedInfoWrapper>;
374 }; 377 };
375 378
376 } // namespace internal 379 } // namespace internal
377 } // namespace v8 380 } // namespace v8
378 381
379 #endif /* V8_DEBUG_LIVEEDIT_H_ */ 382 #endif /* V8_DEBUG_LIVEEDIT_H_ */
OLDNEW
« no previous file with comments | « src/ast/ast-traversal-visitor.h ('k') | src/debug/liveedit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698