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

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

Issue 10796004: Consolidate a few fields in RawFunction using bitfields. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 4 months 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 | « runtime/vm/object.cc ('k') | runtime/vm/parser.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/assembler.h" 6 #include "vm/assembler.h"
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/object_store.h" 10 #include "vm/object_store.h"
(...skipping 12 matching lines...) Expand all
23 // Class has no fields. 23 // Class has no fields.
24 const Array& no_fields = Array::Handle(Array::Empty()); 24 const Array& no_fields = Array::Handle(Array::Empty());
25 cls.SetFields(no_fields); 25 cls.SetFields(no_fields);
26 26
27 // Create and populate the function arrays. 27 // Create and populate the function arrays.
28 const Array& functions = Array::Handle(Array::New(6)); 28 const Array& functions = Array::Handle(Array::New(6));
29 Function& function = Function::Handle(); 29 Function& function = Function::Handle();
30 String& function_name = String::Handle(); 30 String& function_name = String::Handle();
31 function_name = Symbols::New("foo"); 31 function_name = Symbols::New("foo");
32 function = Function::New( 32 function = Function::New(
33 function_name, RawFunction::kRegularFunction, false, false, false, 0); 33 function_name, RawFunction::kRegularFunction,
34 false, false, false, false, 0);
34 functions.SetAt(0, function); 35 functions.SetAt(0, function);
35 function_name = Symbols::New("bar"); 36 function_name = Symbols::New("bar");
36 function = Function::New( 37 function = Function::New(
37 function_name, RawFunction::kRegularFunction, false, false, false, 0); 38 function_name, RawFunction::kRegularFunction,
39 false, false, false, false, 0);
38 40
39 const int kNumFixedParameters = 2; 41 const int kNumFixedParameters = 2;
40 const int kNumOptionalParameters = 3; 42 const int kNumOptionalParameters = 3;
41 function.set_num_fixed_parameters(kNumFixedParameters); 43 function.set_num_fixed_parameters(kNumFixedParameters);
42 function.set_num_optional_parameters(kNumOptionalParameters); 44 function.set_num_optional_parameters(kNumOptionalParameters);
43 functions.SetAt(1, function); 45 functions.SetAt(1, function);
44 46
45 function_name = Symbols::New("baz"); 47 function_name = Symbols::New("baz");
46 function = Function::New( 48 function = Function::New(
47 function_name, RawFunction::kRegularFunction, false, false, false, 0); 49 function_name, RawFunction::kRegularFunction,
50 false, false, false, false, 0);
48 functions.SetAt(2, function); 51 functions.SetAt(2, function);
49 52
50 function_name = Symbols::New("Foo"); 53 function_name = Symbols::New("Foo");
51 function = Function::New( 54 function = Function::New(
52 function_name, RawFunction::kRegularFunction, true, false, false, 0); 55 function_name, RawFunction::kRegularFunction,
56 true, false, false, false, 0);
57
53 functions.SetAt(3, function); 58 functions.SetAt(3, function);
54 function_name = Symbols::New("Bar"); 59 function_name = Symbols::New("Bar");
55 function = Function::New( 60 function = Function::New(
56 function_name, RawFunction::kRegularFunction, true, false, false, 0); 61 function_name, RawFunction::kRegularFunction,
62 true, false, false, false, 0);
57 functions.SetAt(4, function); 63 functions.SetAt(4, function);
58 function_name = Symbols::New("BaZ"); 64 function_name = Symbols::New("BaZ");
59 function = Function::New( 65 function = Function::New(
60 function_name, RawFunction::kRegularFunction, true, false, false, 0); 66 function_name, RawFunction::kRegularFunction,
67 true, false, false, false, 0);
61 functions.SetAt(5, function); 68 functions.SetAt(5, function);
62 69
63 // Setup the functions in the class. 70 // Setup the functions in the class.
64 cls.SetFunctions(functions); 71 cls.SetFunctions(functions);
65 72
66 function_name = String::New("Foo"); 73 function_name = String::New("Foo");
67 function = cls.LookupDynamicFunction(function_name); 74 function = cls.LookupDynamicFunction(function_name);
68 EXPECT(function.IsNull()); 75 EXPECT(function.IsNull());
69 function = cls.LookupStaticFunction(function_name); 76 function = cls.LookupStaticFunction(function_name);
70 EXPECT(!function.IsNull()); 77 EXPECT(!function.IsNull());
(...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 const String& class_name = String::Handle(Symbols::New("MyClass")); 2326 const String& class_name = String::Handle(Symbols::New("MyClass"));
2320 const Script& script = Script::Handle(); 2327 const Script& script = Script::Handle();
2321 const Class& cls = 2328 const Class& cls =
2322 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); 2329 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex));
2323 const Array& functions = Array::Handle(Array::New(1)); 2330 const Array& functions = Array::Handle(Array::New(1));
2324 2331
2325 const Context& context = Context::Handle(Context::New(0)); 2332 const Context& context = Context::Handle(Context::New(0));
2326 Function& parent = Function::Handle(); 2333 Function& parent = Function::Handle();
2327 const String& parent_name = String::Handle(Symbols::New("foo_papa")); 2334 const String& parent_name = String::Handle(Symbols::New("foo_papa"));
2328 parent = Function::New(parent_name, RawFunction::kRegularFunction, 2335 parent = Function::New(parent_name, RawFunction::kRegularFunction,
2329 false, false, false, 0); 2336 false, false, false, false, 0);
2330 functions.SetAt(0, parent); 2337 functions.SetAt(0, parent);
2331 cls.SetFunctions(functions); 2338 cls.SetFunctions(functions);
2332 2339
2333 Function& function = Function::Handle(); 2340 Function& function = Function::Handle();
2334 const String& function_name = String::Handle(Symbols::New("foo")); 2341 const String& function_name = String::Handle(Symbols::New("foo"));
2335 function = Function::NewClosureFunction(function_name, parent, 0); 2342 function = Function::NewClosureFunction(function_name, parent, 0);
2336 const Class& signature_class = Class::Handle( 2343 const Class& signature_class = Class::Handle(
2337 Class::NewSignatureClass(function_name, function, script)); 2344 Class::NewSignatureClass(function_name, function, script));
2338 const Closure& closure = Closure::Handle(Closure::New(function, context)); 2345 const Closure& closure = Closure::Handle(Closure::New(function, context));
2339 const Class& closure_class = Class::Handle(closure.clazz()); 2346 const Class& closure_class = Class::Handle(closure.clazz());
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2389 } 2396 }
2390 2397
2391 2398
2392 // only ia32 and x64 can run execution tests. 2399 // only ia32 and x64 can run execution tests.
2393 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) 2400 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
2394 2401
2395 static Function* CreateFunction(const char* name) { 2402 static Function* CreateFunction(const char* name) {
2396 const String& function_name = String::ZoneHandle(Symbols::New(name)); 2403 const String& function_name = String::ZoneHandle(Symbols::New(name));
2397 Function& function = Function::ZoneHandle( 2404 Function& function = Function::ZoneHandle(
2398 Function::New(function_name, RawFunction::kRegularFunction, 2405 Function::New(function_name, RawFunction::kRegularFunction,
2399 true, false, false, 0)); 2406 true, false, false, false, 0));
2400 return &function; 2407 return &function;
2401 } 2408 }
2402 2409
2403 // Test for Code and Instruction object creation. 2410 // Test for Code and Instruction object creation.
2404 TEST_CASE(Code) { 2411 TEST_CASE(Code) {
2405 extern void GenerateIncrement(Assembler* assembler); 2412 extern void GenerateIncrement(Assembler* assembler);
2406 Assembler _assembler_; 2413 Assembler _assembler_;
2407 GenerateIncrement(&_assembler_); 2414 GenerateIncrement(&_assembler_);
2408 Code& code = Code::Handle(Code::FinalizeCode( 2415 Code& code = Code::Handle(Code::FinalizeCode(
2409 *CreateFunction("Test_Code"), &_assembler_)); 2416 *CreateFunction("Test_Code"), &_assembler_));
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
2573 count++; 2580 count++;
2574 } 2581 }
2575 ASSERT(count == 2); 2582 ASSERT(count == 2);
2576 } 2583 }
2577 2584
2578 2585
2579 static RawFunction* GetDummyTarget(const char* name) { 2586 static RawFunction* GetDummyTarget(const char* name) {
2580 const String& function_name = String::Handle(Symbols::New(name)); 2587 const String& function_name = String::Handle(Symbols::New(name));
2581 const bool is_static = false; 2588 const bool is_static = false;
2582 const bool is_const = false; 2589 const bool is_const = false;
2590 const bool is_abstract = false;
2583 const bool is_external = false; 2591 const bool is_external = false;
2584 return Function::New(function_name, 2592 return Function::New(function_name,
2585 RawFunction::kRegularFunction, 2593 RawFunction::kRegularFunction,
2586 is_static, 2594 is_static,
2587 is_const, 2595 is_const,
2596 is_abstract,
2588 is_external, 2597 is_external,
2589 0); 2598 0);
2590 } 2599 }
2591 2600
2592 2601
2593 TEST_CASE(ICData) { 2602 TEST_CASE(ICData) {
2594 Function& function = Function::Handle(GetDummyTarget("Bern")); 2603 Function& function = Function::Handle(GetDummyTarget("Bern"));
2595 const intptr_t id = 12; 2604 const intptr_t id = 12;
2596 const intptr_t num_args_tested = 1; 2605 const intptr_t num_args_tested = 1;
2597 const String& target_name = String::Handle(String::New("Thun")); 2606 const String& target_name = String::Handle(String::New("Thun"));
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 // Named double-private constructor mismatch. 2793 // Named double-private constructor mismatch.
2785 mangled_name = OneByteString::New("foo@12345.named@12345"); 2794 mangled_name = OneByteString::New("foo@12345.named@12345");
2786 bare_name = OneByteString::New("foo.name"); 2795 bare_name = OneByteString::New("foo.name");
2787 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); 2796 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name));
2788 } 2797 }
2789 2798
2790 2799
2791 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 2800 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
2792 2801
2793 } // namespace dart 2802 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698