Line data Source code
1 : // Copyright 2019 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_CCTEST_COMPILER_SERIALIZER_TESTER_H_
6 : #define V8_CCTEST_COMPILER_SERIALIZER_TESTER_H_
7 :
8 : #include "src/compiler/js-heap-broker.h"
9 : #include "test/cctest/cctest.h"
10 :
11 : namespace v8 {
12 : namespace internal {
13 : namespace compiler {
14 :
15 : class ZoneStats;
16 :
17 : // The purpose of this class is to provide testing facility for the
18 : // SerializerForBackgroundCompilation class. On a high-level, it executes the
19 : // following steps:
20 : // 1. Wraps the provided source in an IIFE
21 : // 2. Generates bytecode for the given source
22 : // 3. Runs the bytecode which *must* return a function
23 : // 4. Takes the returned function and optimizes it
24 : // 5. The optimized function is accessible through `function()`
25 64 : class SerializerTester : public HandleAndZoneScope {
26 : public:
27 : explicit SerializerTester(const char* source);
28 :
29 246 : JSFunctionRef function() const { return function_.value(); }
30 : JSHeapBroker* broker() const { return broker_; }
31 : Isolate* isolate() { return main_isolate(); }
32 :
33 : private:
34 : CanonicalHandleScope canonical_;
35 : base::Optional<JSFunctionRef> function_;
36 : JSHeapBroker* broker_ = nullptr;
37 : };
38 : } // namespace compiler
39 : } // namespace internal
40 : } // namespace v8
41 :
42 : #endif // V8_CCTEST_COMPILER_SERIALIZER_TESTER_H_
|