2019-01-29 12:50:53 +00:00
|
|
|
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_CCTEST_COMPILER_SERIALIZER_TESTER_H_
|
|
|
|
#define V8_CCTEST_COMPILER_SERIALIZER_TESTER_H_
|
|
|
|
|
2019-09-13 16:11:40 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2019-01-29 12:50:53 +00:00
|
|
|
#include "src/compiler/js-heap-broker.h"
|
|
|
|
#include "test/cctest/cctest.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
namespace compiler {
|
|
|
|
|
|
|
|
class ZoneStats;
|
|
|
|
|
2019-01-30 09:09:04 +00:00
|
|
|
// The purpose of this class is to provide testing facility for the
|
|
|
|
// SerializerForBackgroundCompilation class. On a high-level, it executes the
|
|
|
|
// following steps:
|
|
|
|
// 1. Wraps the provided source in an IIFE
|
|
|
|
// 2. Generates bytecode for the given source
|
|
|
|
// 3. Runs the bytecode which *must* return a function
|
|
|
|
// 4. Takes the returned function and optimizes it
|
|
|
|
// 5. The optimized function is accessible through `function()`
|
2019-01-29 12:50:53 +00:00
|
|
|
class SerializerTester : public HandleAndZoneScope {
|
|
|
|
public:
|
|
|
|
explicit SerializerTester(const char* source);
|
|
|
|
|
|
|
|
JSFunctionRef function() const { return function_.value(); }
|
2019-05-02 12:17:06 +00:00
|
|
|
JSHeapBroker* broker() const { return broker_.get(); }
|
2019-01-30 09:09:04 +00:00
|
|
|
Isolate* isolate() { return main_isolate(); }
|
2019-01-29 12:50:53 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
CanonicalHandleScope canonical_;
|
|
|
|
base::Optional<JSFunctionRef> function_;
|
2019-05-02 12:17:06 +00:00
|
|
|
std::unique_ptr<JSHeapBroker> broker_;
|
2019-01-29 12:50:53 +00:00
|
|
|
};
|
|
|
|
} // namespace compiler
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
|
|
|
|
#endif // V8_CCTEST_COMPILER_SERIALIZER_TESTER_H_
|