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

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

Issue 10665038: Remove old code generator. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 5 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/code_generator.h ('k') | runtime/vm/code_generator_arm.h » ('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 "vm/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler_macros.h" 7 #include "vm/assembler_macros.h"
8 #include "vm/ast.h"
8 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
9 #include "vm/compiler.h" 10 #include "vm/compiler.h"
10 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
11 #include "vm/dart_entry.h" 12 #include "vm/dart_entry.h"
12 #include "vm/debugger.h" 13 #include "vm/debugger.h"
13 #include "vm/exceptions.h" 14 #include "vm/exceptions.h"
14 #include "vm/object_store.h" 15 #include "vm/object_store.h"
15 #include "vm/message.h" 16 #include "vm/message.h"
16 #include "vm/message_handler.h" 17 #include "vm/message_handler.h"
17 #include "vm/resolver.h" 18 #include "vm/resolver.h"
(...skipping 10 matching lines...) Expand all
28 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); 29 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls.");
29 DEFINE_FLAG(int, optimization_counter_threshold, 2000, 30 DEFINE_FLAG(int, optimization_counter_threshold, 2000,
30 "function's usage-counter value before it is optimized, -1 means never."); 31 "function's usage-counter value before it is optimized, -1 means never.");
31 DECLARE_FLAG(bool, enable_type_checks); 32 DECLARE_FLAG(bool, enable_type_checks);
32 DECLARE_FLAG(bool, trace_type_checks); 33 DECLARE_FLAG(bool, trace_type_checks);
33 DECLARE_FLAG(bool, report_usage_count); 34 DECLARE_FLAG(bool, report_usage_count);
34 DECLARE_FLAG(int, deoptimization_counter_threshold); 35 DECLARE_FLAG(int, deoptimization_counter_threshold);
35 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function"); 36 DEFINE_FLAG(charp, optimization_filter, NULL, "Optimize only named function");
36 37
37 38
38 bool CodeGenerator::CanOptimize() {
39 return
40 !FLAG_report_usage_count &&
41 (FLAG_optimization_counter_threshold >= 0) &&
42 !Isolate::Current()->debugger()->IsActive();
43 }
44
45
46 const Array& CodeGenerator::ArgumentsDescriptor(
47 int num_arguments,
48 const Array& optional_arguments_names) {
49 const intptr_t num_named_args =
50 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length();
51 const intptr_t num_pos_args = num_arguments - num_named_args;
52
53 // Build the argument descriptor array, which consists of the total number of
54 // arguments, the number of positional arguments, alphabetically sorted
55 // pairs of name/position, and a terminating null.
56 const int descriptor_len = 3 + (2 * num_named_args);
57 Array& descriptor = Array::ZoneHandle(Array::New(descriptor_len, Heap::kOld));
58
59 // Set total number of passed arguments.
60 descriptor.SetAt(0, Smi::Handle(Smi::New(num_arguments)));
61 // Set number of positional arguments.
62 descriptor.SetAt(1, Smi::Handle(Smi::New(num_pos_args)));
63 // Set alphabetically sorted pairs of name/position for named arguments.
64 String& name = String::Handle();
65 Smi& pos = Smi::Handle();
66 for (int i = 0; i < num_named_args; i++) {
67 name ^= optional_arguments_names.At(i);
68 pos = Smi::New(num_pos_args + i);
69 int j = i;
70 // Shift already inserted pairs with "larger" names.
71 String& name_j = String::Handle();
72 Smi& pos_j = Smi::Handle();
73 while (--j >= 0) {
74 name_j ^= descriptor.At(2 + (2 * j));
75 const intptr_t result = name.CompareTo(name_j);
76 ASSERT(result != 0); // Duplicate argument names checked in parser.
77 if (result > 0) break;
78 pos_j ^= descriptor.At(3 + (2 * j));
79 descriptor.SetAt(2 + (2 * (j + 1)), name_j);
80 descriptor.SetAt(3 + (2 * (j + 1)), pos_j);
81 }
82 // Insert pair in descriptor array.
83 descriptor.SetAt(2 + (2 * (j + 1)), name);
84 descriptor.SetAt(3 + (2 * (j + 1)), pos);
85 }
86 // Set terminating null.
87 descriptor.SetAt(descriptor_len - 1, Object::Handle());
88
89 // Share the immutable descriptor when possible by canonicalizing it.
90 descriptor.MakeImmutable();
91 descriptor ^= descriptor.Canonicalize();
92 return descriptor;
93 }
94
95
96 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) { 39 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) {
97 ASSERT(arguments.Count() == kTraceFunctionEntryRuntimeEntry.argument_count()); 40 ASSERT(arguments.Count() == kTraceFunctionEntryRuntimeEntry.argument_count());
98 const Function& function = Function::CheckedHandle(arguments.At(0)); 41 const Function& function = Function::CheckedHandle(arguments.At(0));
99 const String& function_name = String::Handle(function.name()); 42 const String& function_name = String::Handle(function.name());
100 const String& class_name = 43 const String& class_name =
101 String::Handle(Class::Handle(function.owner()).Name()); 44 String::Handle(Class::Handle(function.owner()).Name());
102 OS::Print("> Entering '%s.%s'\n", 45 OS::Print("> Entering '%s.%s'\n",
103 class_name.ToCString(), function_name.ToCString()); 46 class_name.ToCString(), function_name.ToCString());
104 } 47 }
105 48
(...skipping 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1591 1534
1592 1535
1593 // Adds a pointer to the store buffer. 1536 // Adds a pointer to the store buffer.
1594 // ptr: the address of a field being stored into. 1537 // ptr: the address of a field being stored into.
1595 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBuffer, uword ptr) { 1538 DEFINE_LEAF_RUNTIME_ENTRY(void, StoreBuffer, uword ptr) {
1596 Isolate::Current()->store_buffer()->AddPointer(ptr); 1539 Isolate::Current()->store_buffer()->AddPointer(ptr);
1597 } 1540 }
1598 END_LEAF_RUNTIME_ENTRY 1541 END_LEAF_RUNTIME_ENTRY
1599 1542
1600 } // namespace dart 1543 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/code_generator_arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698