Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: runtime/vm/code_descriptors_test.cc

Issue 11364166: Make sure that ParsedFunction holds onto zone handles. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/globals.h" 6 #include "vm/globals.h"
7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
8 8
9 #include "vm/ast.h" 9 #include "vm/ast.h"
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/code_descriptors.h" 11 #include "vm/code_descriptors.h"
12 #include "vm/compiler.h" 12 #include "vm/compiler.h"
13 #include "vm/dart_entry.h" 13 #include "vm/dart_entry.h"
14 #include "vm/native_entry.h" 14 #include "vm/native_entry.h"
15 #include "vm/parser.h" 15 #include "vm/parser.h"
16 #include "vm/symbols.h" 16 #include "vm/symbols.h"
17 #include "vm/unit_test.h" 17 #include "vm/unit_test.h"
18 18
19 namespace dart { 19 namespace dart {
20 20
21 static const intptr_t kPos = Scanner::kDummyTokenIndex; 21 static const intptr_t kPos = Scanner::kDummyTokenIndex;
22 22
23 23
24 CODEGEN_TEST_GENERATE(StackmapCodegen, test) { 24 CODEGEN_TEST_GENERATE(StackmapCodegen, test) {
25 Assembler assembler; 25 Assembler assembler;
26 const String& function_name = String::ZoneHandle(Symbols::New("test")); 26 const String& function_name = String::ZoneHandle(Symbols::New("test"));
27 Class& cls = Class::ZoneHandle(); 27 Class& cls = Class::ZoneHandle();
28 const Script& script = Script::Handle(); 28 const Script& script = Script::Handle();
29 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex); 29 cls = Class::New(function_name, script, Scanner::kDummyTokenIndex);
30 const Function& function = Function::Handle( 30 const Function& function = Function::ZoneHandle(
31 Function::New(function_name, RawFunction::kRegularFunction, 31 Function::New(function_name, RawFunction::kRegularFunction,
32 true, false, false, false, cls, 0)); 32 true, false, false, false, cls, 0));
33 function.set_result_type(Type::Handle(Type::DynamicType())); 33 function.set_result_type(Type::Handle(Type::DynamicType()));
34 const Array& functions = Array::Handle(Array::New(1)); 34 const Array& functions = Array::Handle(Array::New(1));
35 functions.SetAt(0, function); 35 functions.SetAt(0, function);
36 cls.SetFunctions(functions); 36 cls.SetFunctions(functions);
37 Library& lib = Library::Handle(Library::CoreLibrary()); 37 Library& lib = Library::Handle(Library::CoreLibrary());
38 lib.AddClass(cls); 38 lib.AddClass(cls);
39 ParsedFunction* parsed_function = new ParsedFunction(function); 39 ParsedFunction* parsed_function = new ParsedFunction(function);
40 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1))); 40 LiteralNode* l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(1)));
41 test->node_sequence()->Add(new ReturnNode(kPos, l)); 41 test->node_sequence()->Add(new ReturnNode(kPos, l));
42 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2))); 42 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(2)));
43 test->node_sequence()->Add(new ReturnNode(kPos, l)); 43 test->node_sequence()->Add(new ReturnNode(kPos, l));
44 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3))); 44 l = new LiteralNode(kPos, Smi::ZoneHandle(Smi::New(3)));
45 test->node_sequence()->Add(new ReturnNode(kPos, l)); 45 test->node_sequence()->Add(new ReturnNode(kPos, l));
46 parsed_function->SetNodeSequence(test->node_sequence()); 46 parsed_function->SetNodeSequence(test->node_sequence());
47 parsed_function->set_instantiator(NULL); 47 parsed_function->set_instantiator(NULL);
48 parsed_function->set_default_parameter_values(Array::Handle()); 48 parsed_function->set_default_parameter_values(Array::ZoneHandle());
49 parsed_function->AllocateVariables(); 49 parsed_function->AllocateVariables();
50 bool retval; 50 bool retval;
51 Isolate* isolate = Isolate::Current(); 51 Isolate* isolate = Isolate::Current();
52 EXPECT(isolate != NULL); 52 EXPECT(isolate != NULL);
53 LongJump* base = isolate->long_jump_base(); 53 LongJump* base = isolate->long_jump_base();
54 LongJump jump; 54 LongJump jump;
55 isolate->set_long_jump_base(&jump); 55 isolate->set_long_jump_base(&jump);
56 if (setjmp(*jump.Set()) == 0) { 56 if (setjmp(*jump.Set()) == 0) {
57 // Build a stackmap table and some stackmap table entries. 57 // Build a stackmap table and some stackmap table entries.
58 const intptr_t kStackSlotCount = 11; 58 const intptr_t kStackSlotCount = 11;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 GrowableArray<const Object*> arguments; 280 GrowableArray<const Object*> arguments;
281 const Array& kNoArgumentNames = Array::Handle(); 281 const Array& kNoArgumentNames = Array::Handle();
282 Object& result = Object::Handle(); 282 Object& result = Object::Handle();
283 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames); 283 result = DartEntry::InvokeStatic(function_foo, arguments, kNoArgumentNames);
284 EXPECT(!result.IsError()); 284 EXPECT(!result.IsError());
285 } 285 }
286 286
287 } // namespace dart 287 } // namespace dart
288 288
289 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) 289 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64)
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698