Remove CompilationInfoWithZone from public API.
This removes the CompilationInfoWithZone class from the header file because it is more than a pure convenience class and shouldn't be used outside of the compiler at all. R=titzer@chromium.org Review URL: https://codereview.chromium.org/1000353004 Cr-Commit-Position: refs/heads/master@{#27411}
This commit is contained in:
parent
125d31ecfd
commit
1fefa31df6
@ -74,6 +74,28 @@ PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info)
|
||||
#undef PARSE_INFO_GETTER_WITH_DEFAULT
|
||||
|
||||
|
||||
// Exactly like a CompilationInfo, except being allocated via {new} and it also
|
||||
// creates and enters a Zone on construction and deallocates it on destruction.
|
||||
class CompilationInfoWithZone : public CompilationInfo {
|
||||
public:
|
||||
explicit CompilationInfoWithZone(Handle<JSFunction> function)
|
||||
: CompilationInfo(new ParseInfo(&zone_, function)) {}
|
||||
|
||||
// Virtual destructor because a CompilationInfoWithZone has to exit the
|
||||
// zone scope and get rid of dependent maps even when the destructor is
|
||||
// called when cast as a CompilationInfo.
|
||||
virtual ~CompilationInfoWithZone() {
|
||||
DisableFutureOptimization();
|
||||
RollbackDependencies();
|
||||
delete parse_info_;
|
||||
parse_info_ = nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
};
|
||||
|
||||
|
||||
bool CompilationInfo::has_shared_info() const {
|
||||
return parse_info_ && !parse_info_->shared_info().is_null();
|
||||
}
|
||||
@ -1007,7 +1029,9 @@ MaybeHandle<Code> Compiler::GetDebugCode(Handle<JSFunction> function) {
|
||||
|
||||
void Compiler::CompileForLiveEdit(Handle<Script> script) {
|
||||
// TODO(635): support extensions.
|
||||
CompilationInfoWithZone info(script);
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, script);
|
||||
CompilationInfo info(&parse_info);
|
||||
PostponeInterruptsScope postpone(info.isolate());
|
||||
VMState<COMPILER> state(info.isolate());
|
||||
|
||||
@ -1145,13 +1169,14 @@ MaybeHandle<JSFunction> Compiler::GetFunctionFromEval(
|
||||
|
||||
if (!maybe_shared_info.ToHandle(&shared_info)) {
|
||||
Handle<Script> script = isolate->factory()->NewScript(source);
|
||||
CompilationInfoWithZone info(script);
|
||||
ParseInfo* parse_info = info.parse_info();
|
||||
parse_info->set_eval();
|
||||
if (context->IsNativeContext()) parse_info->set_global();
|
||||
parse_info->set_language_mode(language_mode);
|
||||
parse_info->set_parse_restriction(restriction);
|
||||
parse_info->set_context(context);
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, script);
|
||||
CompilationInfo info(&parse_info);
|
||||
parse_info.set_eval();
|
||||
if (context->IsNativeContext()) parse_info.set_global();
|
||||
parse_info.set_language_mode(language_mode);
|
||||
parse_info.set_parse_restriction(restriction);
|
||||
parse_info.set_context(context);
|
||||
|
||||
Debug::RecordEvalCaller(script);
|
||||
|
||||
@ -1268,25 +1293,26 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(
|
||||
}
|
||||
|
||||
// Compile the function and add it to the cache.
|
||||
CompilationInfoWithZone info(script);
|
||||
ParseInfo* parse_info = info.parse_info();
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, script);
|
||||
CompilationInfo info(&parse_info);
|
||||
if (FLAG_harmony_modules && is_module) {
|
||||
parse_info->set_module();
|
||||
parse_info.set_module();
|
||||
} else {
|
||||
parse_info->set_global();
|
||||
parse_info.set_global();
|
||||
}
|
||||
if (compile_options != ScriptCompiler::kNoCompileOptions) {
|
||||
parse_info->set_cached_data(cached_data);
|
||||
parse_info.set_cached_data(cached_data);
|
||||
}
|
||||
parse_info->set_compile_options(compile_options);
|
||||
parse_info->set_extension(extension);
|
||||
parse_info->set_context(context);
|
||||
parse_info.set_compile_options(compile_options);
|
||||
parse_info.set_extension(extension);
|
||||
parse_info.set_context(context);
|
||||
if (FLAG_serialize_toplevel &&
|
||||
compile_options == ScriptCompiler::kProduceCodeCache) {
|
||||
info.PrepareForSerializing();
|
||||
}
|
||||
|
||||
parse_info->set_language_mode(
|
||||
parse_info.set_language_mode(
|
||||
static_cast<LanguageMode>(info.language_mode() | language_mode));
|
||||
result = CompileToplevel(&info);
|
||||
if (extension == NULL && !result.is_null() && !result->dont_cache()) {
|
||||
@ -1334,11 +1360,12 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
|
||||
FunctionLiteral* literal, Handle<Script> script,
|
||||
CompilationInfo* outer_info) {
|
||||
// Precondition: code has been parsed and scopes have been analyzed.
|
||||
CompilationInfoWithZone info(script);
|
||||
ParseInfo* parse_info = info.parse_info();
|
||||
parse_info->set_literal(literal);
|
||||
parse_info->set_scope(literal->scope());
|
||||
parse_info->set_language_mode(literal->scope()->language_mode());
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, script);
|
||||
CompilationInfo info(&parse_info);
|
||||
parse_info.set_literal(literal);
|
||||
parse_info.set_scope(literal->scope());
|
||||
parse_info.set_language_mode(literal->scope()->language_mode());
|
||||
if (outer_info->will_serialize()) info.PrepareForSerializing();
|
||||
|
||||
Isolate* isolate = info.isolate();
|
||||
@ -1548,21 +1575,6 @@ bool CompilationPhase::ShouldProduceTraceOutput() const {
|
||||
}
|
||||
|
||||
|
||||
CompilationInfoWithZone::CompilationInfoWithZone(Handle<Script> script)
|
||||
: CompilationInfo(new ParseInfo(&zone_, script)) {}
|
||||
|
||||
|
||||
CompilationInfoWithZone::CompilationInfoWithZone(Handle<JSFunction> function)
|
||||
: CompilationInfo(new ParseInfo(&zone_, function)) {}
|
||||
|
||||
|
||||
CompilationInfoWithZone::~CompilationInfoWithZone() {
|
||||
DisableFutureOptimization();
|
||||
RollbackDependencies();
|
||||
delete parse_info_;
|
||||
parse_info_ = nullptr;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
void CompilationInfo::PrintAstForTesting() {
|
||||
PrintF("--- Source from AST ---\n%s\n",
|
||||
|
@ -486,22 +486,6 @@ class CompilationInfo {
|
||||
};
|
||||
|
||||
|
||||
// Exactly like a CompilationInfo, except also creates and enters a
|
||||
// Zone on construction and deallocates it on exit.
|
||||
class CompilationInfoWithZone: public CompilationInfo {
|
||||
public:
|
||||
explicit CompilationInfoWithZone(Handle<Script> script);
|
||||
explicit CompilationInfoWithZone(Handle<JSFunction> closure);
|
||||
|
||||
// Virtual destructor because a CompilationInfoWithZone has to exit the
|
||||
// zone scope and get rid of dependent maps even when the destructor is
|
||||
// called when cast as a CompilationInfo.
|
||||
virtual ~CompilationInfoWithZone();
|
||||
|
||||
private:
|
||||
Zone zone_;
|
||||
};
|
||||
|
||||
// A wrapper around a CompilationInfo that detaches the Handles from
|
||||
// the underlying DeferredHandleScope and stores them in info_ on
|
||||
// destruction.
|
||||
|
@ -320,7 +320,9 @@ Reduction JSInliner::Reduce(Node* node) {
|
||||
return NoChange();
|
||||
}
|
||||
|
||||
CompilationInfoWithZone info(function);
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, function);
|
||||
CompilationInfo info(&parse_info);
|
||||
|
||||
if (!Compiler::ParseAndAnalyze(info.parse_info())) return NoChange();
|
||||
if (!Compiler::EnsureDeoptimizationSupport(&info)) return NoChange();
|
||||
|
@ -150,7 +150,9 @@ class FunctionTester : public InitializedHandleScope {
|
||||
Handle<JSFunction> Compile(Handle<JSFunction> function) {
|
||||
// TODO(titzer): make this method private.
|
||||
#if V8_TURBOFAN_TARGET
|
||||
CompilationInfoWithZone info(function);
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, function);
|
||||
CompilationInfo info(&parse_info);
|
||||
|
||||
CHECK(Parser::ParseStatic(info.parse_info()));
|
||||
info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
|
||||
@ -206,7 +208,9 @@ class FunctionTester : public InitializedHandleScope {
|
||||
// and replace the JSFunction's code with the result.
|
||||
Handle<JSFunction> CompileGraph(Graph* graph) {
|
||||
CHECK(Pipeline::SupportedTarget());
|
||||
CompilationInfoWithZone info(function);
|
||||
Zone zone;
|
||||
ParseInfo parse_info(&zone, function);
|
||||
CompilationInfo info(&parse_info);
|
||||
|
||||
CHECK(Parser::ParseStatic(info.parse_info()));
|
||||
info.SetOptimizing(BailoutId::None(),
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/parser.h"
|
||||
#include "src/zone.h"
|
||||
|
||||
#include "src/compiler/common-operator.h"
|
||||
@ -42,25 +43,25 @@ static Handle<JSFunction> Compile(const char* source) {
|
||||
|
||||
|
||||
TEST(TestLinkageCreate) {
|
||||
InitializedHandleScope handles;
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + b");
|
||||
CompilationInfoWithZone info(function);
|
||||
ParseInfo parse_info(handles.main_zone(), function);
|
||||
CompilationInfo info(&parse_info);
|
||||
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(descriptor);
|
||||
}
|
||||
|
||||
|
||||
TEST(TestLinkageJSFunctionIncoming) {
|
||||
InitializedHandleScope handles;
|
||||
|
||||
const char* sources[] = {"(function() { })", "(function(a) { })",
|
||||
"(function(a,b) { })", "(function(a,b,c) { })"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
i::HandleScope handles(CcTest::i_isolate());
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = v8::Utils::OpenHandle(
|
||||
*v8::Handle<v8::Function>::Cast(CompileRun(sources[i])));
|
||||
CompilationInfoWithZone info(function);
|
||||
ParseInfo parse_info(handles.main_zone(), function);
|
||||
CompilationInfo info(&parse_info);
|
||||
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(descriptor);
|
||||
|
||||
@ -89,7 +90,8 @@ TEST(TestLinkageCodeStubIncoming) {
|
||||
TEST(TestLinkageJSCall) {
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + c");
|
||||
CompilationInfoWithZone info(function);
|
||||
ParseInfo parse_info(handles.main_zone(), function);
|
||||
CompilationInfo info(&parse_info);
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
|
||||
|
@ -17,13 +17,13 @@ using namespace v8::internal;
|
||||
using namespace v8::internal::compiler;
|
||||
|
||||
TEST(PipelineAdd) {
|
||||
InitializedHandleScope handles;
|
||||
HandleAndZoneScope handles;
|
||||
const char* source = "(function(a,b) { return a + b; })";
|
||||
Handle<JSFunction> function = v8::Utils::OpenHandle(
|
||||
*v8::Handle<v8::Function>::Cast(CompileRun(source)));
|
||||
CompilationInfoWithZone info(function);
|
||||
|
||||
CHECK(Compiler::ParseAndAnalyze(info.parse_info()));
|
||||
ParseInfo parse_info(handles.main_zone(), function);
|
||||
CHECK(Compiler::ParseAndAnalyze(&parse_info));
|
||||
CompilationInfo info(&parse_info);
|
||||
|
||||
Pipeline pipeline(&info);
|
||||
#if V8_TURBOFAN_TARGET
|
||||
|
@ -42,8 +42,10 @@ class StringLengthStubTF : public CodeStub {
|
||||
};
|
||||
|
||||
Handle<Code> GenerateCode() OVERRIDE {
|
||||
Zone zone;
|
||||
// Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
|
||||
CompilationInfoWithZone info(GetFunction(isolate(), "STRING_LENGTH_STUB"));
|
||||
ParseInfo parse_info(&zone, GetFunction(isolate(), "STRING_LENGTH_STUB"));
|
||||
CompilationInfo info(&parse_info);
|
||||
info.SetStub(this);
|
||||
// Run a "mini pipeline", extracted from compiler.cc.
|
||||
CHECK(Parser::ParseStatic(info.parse_info()));
|
||||
|
Loading…
Reference in New Issue
Block a user