From 2fdbeb2153bbd335461e3854f024263b399f310e Mon Sep 17 00:00:00 2001 From: "srdjan@google.com" Date: Fri, 9 Nov 2012 00:58:21 +0000 Subject: [PATCH] Make sure that ParsedFunction holds onto zone handles. Review URL: https://codereview.chromium.org//11364166 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14718 260f80e4-7a28-3924-810f-c04153c831b5 --- runtime/vm/code_descriptors_test.cc | 4 ++-- runtime/vm/compiler.cc | 7 ++++--- runtime/vm/parser.cc | 2 +- runtime/vm/parser.h | 7 +++++-- runtime/vm/parser_test.cc | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/runtime/vm/code_descriptors_test.cc b/runtime/vm/code_descriptors_test.cc index ae4aa0cb50b..f25523206ef 100644 --- a/runtime/vm/code_descriptors_test.cc +++ b/runtime/vm/code_descriptors_test.cc @@ -27,7 +27,7 @@ CODEGEN_TEST_GENERATE(StackmapCodegen, test) { Class& cls = Class::ZoneHandle(); const Script& script = Script::Handle(); cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); - const Function& function = Function::Handle( + const Function& function = Function::ZoneHandle( Function::New(function_name, RawFunction::kRegularFunction, true, false, false, false, cls, 0)); function.set_result_type(Type::Handle(Type::DynamicType())); @@ -45,7 +45,7 @@ CODEGEN_TEST_GENERATE(StackmapCodegen, test) { test->node_sequence()->Add(new ReturnNode(kPos, l)); parsed_function->SetNodeSequence(test->node_sequence()); parsed_function->set_instantiator(NULL); - parsed_function->set_default_parameter_values(Array::Handle()); + parsed_function->set_default_parameter_values(Array::ZoneHandle()); parsed_function->AllocateVariables(); bool retval; Isolate* isolate = Isolate::Current(); diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc index 16c426eba14..0f6b03675a3 100644 --- a/runtime/vm/compiler.cc +++ b/runtime/vm/compiler.cc @@ -435,7 +435,8 @@ static RawError* CompileFunctionHelper(const Function& function, TIMERSCOPE(time_compilation); Timer per_compile_timer(FLAG_trace_compiler, "Compilation time"); per_compile_timer.Start(); - ParsedFunction* parsed_function = new ParsedFunction(function); + ParsedFunction* parsed_function = new ParsedFunction( + Function::ZoneHandle(function.raw())); if (FLAG_trace_compiler) { OS::Print("Compiling %sfunction: '%s' @ token %"Pd"\n", (optimized ? "optimized " : ""), @@ -561,7 +562,7 @@ RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { // The function needs to be associated with a named Class: the interface // Function fits the bill. const char* kEvalConst = "eval_const"; - const Function& func = Function::Handle(Function::New( + const Function& func = Function::ZoneHandle(Function::New( String::Handle(Symbols::New(kEvalConst)), RawFunction::kConstImplicitGetter, true, // static function. @@ -582,7 +583,7 @@ RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { // here. ParsedFunction* parsed_function = new ParsedFunction(func); parsed_function->SetNodeSequence(fragment); - parsed_function->set_default_parameter_values(Array::Handle()); + parsed_function->set_default_parameter_values(Array::ZoneHandle()); parsed_function->set_expression_temp_var( ParsedFunction::CreateExpressionTempVar(0)); fragment->scope()->AddVariable(parsed_function->expression_temp_var()); diff --git a/runtime/vm/parser.cc b/runtime/vm/parser.cc index 15b144e4fd9..668c0bfddef 100644 --- a/runtime/vm/parser.cc +++ b/runtime/vm/parser.cc @@ -772,7 +772,7 @@ void Parser::ParseFunction(ParsedFunction* parsed_function) { const Script& script = Script::Handle(isolate, func.script()); Parser parser(script, func, func.token_pos()); SequenceNode* node_sequence = NULL; - Array& default_parameter_values = Array::Handle(isolate, Array::null()); + Array& default_parameter_values = Array::ZoneHandle(isolate, Array::null()); switch (func.kind()) { case RawFunction::kRegularFunction: case RawFunction::kClosureFunction: diff --git a/runtime/vm/parser.h b/runtime/vm/parser.h index 69d27af2fa4..e3c082d93c3 100644 --- a/runtime/vm/parser.h +++ b/runtime/vm/parser.h @@ -36,13 +36,15 @@ class ParsedFunction : public ZoneAllocated { : function_(function), node_sequence_(NULL), instantiator_(NULL), - default_parameter_values_(Array::Handle()), + default_parameter_values_(Array::ZoneHandle()), saved_context_var_(NULL), expression_temp_var_(NULL), first_parameter_index_(0), first_stack_local_index_(0), num_copied_params_(0), - num_stack_locals_(0) { } + num_stack_locals_(0) { + ASSERT(function.IsZoneHandle()); + } const Function& function() const { return function_; } @@ -59,6 +61,7 @@ class ParsedFunction : public ZoneAllocated { return default_parameter_values_; } void set_default_parameter_values(const Array& default_parameter_values) { + ASSERT(default_parameter_values.IsZoneHandle()); default_parameter_values_ = default_parameter_values.raw(); } diff --git a/runtime/vm/parser_test.cc b/runtime/vm/parser_test.cc index 99433c57a68..f04eef1cf0f 100644 --- a/runtime/vm/parser_test.cc +++ b/runtime/vm/parser_test.cc @@ -20,7 +20,7 @@ void DumpFunction(const Library& lib, const char* cname, const char* fname) { EXPECT(!cls.IsNull()); String& funcname = String::Handle(String::New(fname)); - Function& function = Function::Handle(cls.LookupStaticFunction(funcname)); + Function& function = Function::ZoneHandle(cls.LookupStaticFunction(funcname)); EXPECT(!function.IsNull()); bool retval;