Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/code_index_table.h" | 7 #include "vm/code_index_table.h" |
| 8 #include "vm/code_patcher.h" | 8 #include "vm/code_patcher.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
| 11 #include "vm/dart_entry.h" | 11 #include "vm/dart_entry.h" |
| 12 #include "vm/exceptions.h" | 12 #include "vm/exceptions.h" |
| 13 #include "vm/ic_data.h" | 13 #include "vm/ic_data.h" |
| 14 #include "vm/object_store.h" | 14 #include "vm/object_store.h" |
| 15 #include "vm/resolver.h" | 15 #include "vm/resolver.h" |
| 16 #include "vm/runtime_entry.h" | 16 #include "vm/runtime_entry.h" |
| 17 #include "vm/stack_frame.h" | 17 #include "vm/stack_frame.h" |
| 18 #include "vm/verifier.h" | 18 #include "vm/verifier.h" |
| 19 | 19 |
| 20 namespace dart { | 20 namespace dart { |
| 21 | 21 |
| 22 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); | 22 DEFINE_FLAG(bool, inline_cache, true, "enable inline caches"); |
| 23 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); | 23 DEFINE_FLAG(bool, trace_deopt, false, "Trace deoptimization"); |
| 24 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); | 24 DEFINE_FLAG(bool, trace_ic, false, "trace IC handling"); |
| 25 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); | 25 DEFINE_FLAG(bool, trace_patching, false, "Trace patching of code."); |
| 26 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); | 26 DEFINE_FLAG(bool, trace_runtime_calls, false, "Trace runtime calls."); |
| 27 DECLARE_FLAG(int, deoptimization_counter_threshold); | 27 DECLARE_FLAG(int, deoptimization_counter_threshold); |
| 28 DECLARE_FLAG(bool, trace_type_checks); | |
| 28 | 29 |
| 29 | 30 |
| 30 const Array& CodeGenerator::ArgumentsDescriptor( | 31 const Array& CodeGenerator::ArgumentsDescriptor( |
| 31 int num_arguments, | 32 int num_arguments, |
| 32 const Array& optional_arguments_names) { | 33 const Array& optional_arguments_names) { |
| 33 const intptr_t num_named_args = | 34 const intptr_t num_named_args = |
| 34 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); | 35 optional_arguments_names.IsNull() ? 0 : optional_arguments_names.Length(); |
| 35 const intptr_t num_pos_args = num_arguments - num_named_args; | 36 const intptr_t num_pos_args = num_arguments - num_named_args; |
| 36 | 37 |
| 37 // Build the argument descriptor array, which consists of the total number of | 38 // Build the argument descriptor array, which consists of the total number of |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 ASSERT(arguments.Count() == kInstanceofRuntimeEntry.argument_count()); | 319 ASSERT(arguments.Count() == kInstanceofRuntimeEntry.argument_count()); |
| 319 const Instance& instance = Instance::CheckedHandle(arguments.At(0)); | 320 const Instance& instance = Instance::CheckedHandle(arguments.At(0)); |
| 320 const Type& type = Type::CheckedHandle(arguments.At(1)); | 321 const Type& type = Type::CheckedHandle(arguments.At(1)); |
| 321 const TypeArguments& type_instantiator = | 322 const TypeArguments& type_instantiator = |
| 322 TypeArguments::CheckedHandle(arguments.At(2)); | 323 TypeArguments::CheckedHandle(arguments.At(2)); |
| 323 ASSERT(type.IsFinalized()); | 324 ASSERT(type.IsFinalized()); |
| 324 ASSERT(!instance.IsNull()); | 325 ASSERT(!instance.IsNull()); |
| 325 const Bool& result = Bool::Handle( | 326 const Bool& result = Bool::Handle( |
| 326 instance.IsInstanceOf(type, type_instantiator) ? | 327 instance.IsInstanceOf(type, type_instantiator) ? |
| 327 Bool::True() : Bool::False()); | 328 Bool::True() : Bool::False()); |
| 329 if (FLAG_trace_type_checks) { | |
| 330 Class& cls = Class::Handle(instance.clazz()); | |
| 331 // TODO(regis): Remove once all classes finalized. | |
| 332 if (cls.is_finalized()) { | |
| 333 OS::Print("InstanceOf '%s' vs '%s'\n", | |
|
regis
2011/11/10 03:09:51
You could use the result of the type test to print
srdjan
2011/11/10 17:24:41
Done.
| |
| 334 String::Handle(Type::Handle(instance.GetType()).Name()). | |
| 335 ToCString(), | |
| 336 String::Handle(type.Name()).ToCString()); | |
| 337 } | |
| 338 } | |
| 328 arguments.SetReturn(result); | 339 arguments.SetReturn(result); |
| 329 } | 340 } |
| 330 | 341 |
| 331 | 342 |
| 332 DEFINE_RUNTIME_ENTRY(Throw, 1) { | 343 DEFINE_RUNTIME_ENTRY(Throw, 1) { |
| 333 ASSERT(arguments.Count() == kThrowRuntimeEntry.argument_count()); | 344 ASSERT(arguments.Count() == kThrowRuntimeEntry.argument_count()); |
| 334 const Instance& exception = Instance::CheckedHandle(arguments.At(0)); | 345 const Instance& exception = Instance::CheckedHandle(arguments.At(0)); |
| 335 Exceptions::Throw(exception); | 346 Exceptions::Throw(exception); |
| 336 } | 347 } |
| 337 | 348 |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 981 } | 992 } |
| 982 } | 993 } |
| 983 } | 994 } |
| 984 // The cache is null terminated, therefore the loop above should never | 995 // The cache is null terminated, therefore the loop above should never |
| 985 // terminate by itself. | 996 // terminate by itself. |
| 986 UNREACHABLE(); | 997 UNREACHABLE(); |
| 987 return Code::null(); | 998 return Code::null(); |
| 988 } | 999 } |
| 989 | 1000 |
| 990 } // namespace dart | 1001 } // namespace dart |
| OLD | NEW |