| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.h" | 7 #include "vm/assembler.h" |
| 8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
| 9 #include "vm/bigint_operations.h" | 9 #include "vm/bigint_operations.h" |
| 10 #include "vm/code_patcher.h" | 10 #include "vm/code_patcher.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 DEFINE_FLAG(int, stacktrace_every, 0, | 64 DEFINE_FLAG(int, stacktrace_every, 0, |
| 65 "Compute debugger stacktrace on every N stack overflow checks"); | 65 "Compute debugger stacktrace on every N stack overflow checks"); |
| 66 DEFINE_FLAG(charp, stacktrace_filter, NULL, | 66 DEFINE_FLAG(charp, stacktrace_filter, NULL, |
| 67 "Compute stacktrace in named function on stack overflow checks"); | 67 "Compute stacktrace in named function on stack overflow checks"); |
| 68 DEFINE_FLAG(int, deoptimize_every, 0, | 68 DEFINE_FLAG(int, deoptimize_every, 0, |
| 69 "Deoptimize on every N stack overflow checks"); | 69 "Deoptimize on every N stack overflow checks"); |
| 70 DEFINE_FLAG(charp, deoptimize_filter, NULL, | 70 DEFINE_FLAG(charp, deoptimize_filter, NULL, |
| 71 "Deoptimize in named function on stack overflow checks"); | 71 "Deoptimize in named function on stack overflow checks"); |
| 72 | 72 |
| 73 #ifdef DEBUG |
| 74 DEFINE_FLAG(charp, gc_at_instance_allocation, NULL, |
| 75 "Perform a GC before allocation of instances of " |
| 76 "the specified class"); |
| 77 #endif |
| 73 | 78 |
| 74 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) { | 79 DEFINE_RUNTIME_ENTRY(TraceFunctionEntry, 1) { |
| 75 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); | 80 const Function& function = Function::CheckedHandle(arguments.ArgAt(0)); |
| 76 const String& function_name = String::Handle(function.name()); | 81 const String& function_name = String::Handle(function.name()); |
| 77 const String& class_name = | 82 const String& class_name = |
| 78 String::Handle(Class::Handle(function.Owner()).Name()); | 83 String::Handle(Class::Handle(function.Owner()).Name()); |
| 79 OS::PrintErr("> Entering '%s.%s'\n", | 84 OS::PrintErr("> Entering '%s.%s'\n", |
| 80 class_name.ToCString(), function_name.ToCString()); | 85 class_name.ToCString(), function_name.ToCString()); |
| 81 } | 86 } |
| 82 | 87 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 return caller_frame->GetTokenPos(); | 139 return caller_frame->GetTokenPos(); |
| 135 } | 140 } |
| 136 | 141 |
| 137 | 142 |
| 138 // Allocate a new object. | 143 // Allocate a new object. |
| 139 // Arg0: class of the object that needs to be allocated. | 144 // Arg0: class of the object that needs to be allocated. |
| 140 // Arg1: type arguments of the object that needs to be allocated. | 145 // Arg1: type arguments of the object that needs to be allocated. |
| 141 // Return value: newly allocated object. | 146 // Return value: newly allocated object. |
| 142 DEFINE_RUNTIME_ENTRY(AllocateObject, 2) { | 147 DEFINE_RUNTIME_ENTRY(AllocateObject, 2) { |
| 143 const Class& cls = Class::CheckedHandle(arguments.ArgAt(0)); | 148 const Class& cls = Class::CheckedHandle(arguments.ArgAt(0)); |
| 149 |
| 150 #ifdef DEBUG |
| 151 if (FLAG_gc_at_instance_allocation != NULL) { |
| 152 const String& name = String::Handle(cls.Name()); |
| 153 if (String::EqualsIgnoringPrivateKey( |
| 154 name, |
| 155 String::Handle(String::New(FLAG_gc_at_instance_allocation)))) { |
| 156 Isolate::Current()->heap()->CollectAllGarbage(); |
| 157 } |
| 158 } |
| 159 #endif |
| 160 |
| 144 const Instance& instance = Instance::Handle(Instance::New(cls)); | 161 const Instance& instance = Instance::Handle(Instance::New(cls)); |
| 162 |
| 145 arguments.SetReturn(instance); | 163 arguments.SetReturn(instance); |
| 146 if (cls.NumTypeArguments() == 0) { | 164 if (cls.NumTypeArguments() == 0) { |
| 147 // No type arguments required for a non-parameterized type. | 165 // No type arguments required for a non-parameterized type. |
| 148 ASSERT(Instance::CheckedHandle(arguments.ArgAt(1)).IsNull()); | 166 ASSERT(Instance::CheckedHandle(arguments.ArgAt(1)).IsNull()); |
| 149 return; | 167 return; |
| 150 } | 168 } |
| 151 TypeArguments& type_arguments = | 169 TypeArguments& type_arguments = |
| 152 TypeArguments::CheckedHandle(arguments.ArgAt(1)); | 170 TypeArguments::CheckedHandle(arguments.ArgAt(1)); |
| 153 // Unless null (for a raw type), the type argument vector may be longer than | 171 // Unless null (for a raw type), the type argument vector may be longer than |
| 154 // necessary due to a type optimization reusing the type argument vector of | 172 // necessary due to a type optimization reusing the type argument vector of |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 // of the given value. | 1545 // of the given value. |
| 1528 // Arg0: Field object; | 1546 // Arg0: Field object; |
| 1529 // Arg1: Value that is being stored. | 1547 // Arg1: Value that is being stored. |
| 1530 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { | 1548 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { |
| 1531 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); | 1549 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); |
| 1532 const Object& value = Object::Handle(arguments.ArgAt(1)); | 1550 const Object& value = Object::Handle(arguments.ArgAt(1)); |
| 1533 field.RecordStore(value); | 1551 field.RecordStore(value); |
| 1534 } | 1552 } |
| 1535 | 1553 |
| 1536 } // namespace dart | 1554 } // namespace dart |
| OLD | NEW |