blob: a1d31373e7300dbbcc57ec949e10e5f5ba826038 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// Copyright 2014 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_AST_AST_NUMBERING_H_
6#define V8_AST_AST_NUMBERING_H_
7
8namespace v8 {
9namespace internal {
10
11// Forward declarations.
12class FunctionLiteral;
13class Isolate;
14class Zone;
15
16namespace AstNumbering {
Ben Murdochc5610432016-08-08 18:44:38 +010017// Assign type feedback IDs, bailout IDs, and generator yield IDs to an AST node
18// tree.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000019bool Renumber(Isolate* isolate, Zone* zone, FunctionLiteral* function);
20}
21
Ben Murdochc5610432016-08-08 18:44:38 +010022// Some details on yield IDs
23// -------------------------
24//
25// In order to assist Ignition in generating bytecode for a generator function,
26// we assign a unique number (the yield ID) to each Yield node in its AST. We
27// also annotate loops with the number of yields they contain (loop.yield_count)
28// and the smallest ID of those (loop.first_yield_id), and we annotate the
29// function itself with the number of yields it contains (function.yield_count).
30//
31// The way in which we choose the IDs is simply by enumerating the Yield nodes.
32// Ignition relies on the following properties:
33// - For each loop l and each yield y of l:
34// l.first_yield_id <= y.yield_id < l.first_yield_id + l.yield_count
35// - For the generator function f itself and each yield y of f:
36// 0 <= y.yield_id < f.yield_count
37
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000038} // namespace internal
39} // namespace v8
40
41#endif // V8_AST_AST_NUMBERING_H_