OLD | NEW |
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/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
6 | 6 |
7 #include "lib/invocation_mirror.h" | 7 #include "lib/invocation_mirror.h" |
8 #include "vm/ast_printer.h" | 8 #include "vm/ast_printer.h" |
9 #include "vm/bit_vector.h" | 9 #include "vm/bit_vector.h" |
10 #include "vm/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 DEFINE_FLAG(bool, eliminate_type_checks, true, | 34 DEFINE_FLAG(bool, eliminate_type_checks, true, |
35 "Eliminate type checks when allowed by static type analysis."); | 35 "Eliminate type checks when allowed by static type analysis."); |
36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 36 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 37 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
38 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 38 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
39 "Trace type check elimination at compile time."); | 39 "Trace type check elimination at compile time."); |
40 DECLARE_FLAG(bool, enable_type_checks); | 40 DECLARE_FLAG(bool, enable_type_checks); |
41 | 41 |
42 | 42 |
43 | |
44 // TODO(srdjan): Allow compiler to add constants as they are encountered in | 43 // TODO(srdjan): Allow compiler to add constants as they are encountered in |
45 // the compilation. | 44 // the compilation. |
46 const double kCommonDoubleConstants[] = | 45 const double kCommonDoubleConstants[] = |
47 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, | 46 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, |
48 10.0, 20.0, 30.0, 64.0, 255.0, NAN, | 47 10.0, 20.0, 30.0, 64.0, 255.0, NAN, |
49 // From dart:math | 48 // From dart:math |
50 2.718281828459045, 2.302585092994046, 0.6931471805599453, | 49 2.718281828459045, 2.302585092994046, 0.6931471805599453, |
51 1.4426950408889634, 0.4342944819032518, 3.1415926535897932, | 50 1.4426950408889634, 0.4342944819032518, 3.1415926535897932, |
52 0.7071067811865476, 1.4142135623730951}; | 51 0.7071067811865476, 1.4142135623730951}; |
53 | 52 |
54 uword FlowGraphBuilder::FindDoubleConstant(double value) { | 53 uword FlowGraphBuilder::FindDoubleConstant(double value) { |
55 intptr_t len = sizeof(kCommonDoubleConstants) / sizeof(double); // NOLINT | 54 intptr_t len = sizeof(kCommonDoubleConstants) / sizeof(double); // NOLINT |
56 for (intptr_t i = 0; i < len; i++) { | 55 for (intptr_t i = 0; i < len; i++) { |
57 // Bitwise compare. | 56 if (Utils::DoublesBitEqual(value, kCommonDoubleConstants[i])) { |
58 const int64_t* a = reinterpret_cast<const int64_t*>(&value); | |
59 const int64_t* b = | |
60 reinterpret_cast<const int64_t*>(&kCommonDoubleConstants[i]); | |
61 if (*a == *b) { | |
62 return reinterpret_cast<uword>(&kCommonDoubleConstants[i]); | 57 return reinterpret_cast<uword>(&kCommonDoubleConstants[i]); |
63 } | 58 } |
64 } | 59 } |
65 return 0; | 60 return 0; |
66 } | 61 } |
67 | 62 |
68 | 63 |
69 // Base class for a stack of enclosing statements of interest (e.g., | 64 // Base class for a stack of enclosing statements of interest (e.g., |
70 // blocks (breakable) and loops (continuable)). | 65 // blocks (breakable) and loops (continuable)). |
71 class NestedStatement : public ValueObject { | 66 class NestedStatement : public ValueObject { |
(...skipping 3857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3929 function.token_pos(), | 3924 function.token_pos(), |
3930 LanguageError::kError, | 3925 LanguageError::kError, |
3931 Heap::kNew, | 3926 Heap::kNew, |
3932 "FlowGraphBuilder Bailout: %s %s", | 3927 "FlowGraphBuilder Bailout: %s %s", |
3933 String::Handle(function.name()).ToCString(), | 3928 String::Handle(function.name()).ToCString(), |
3934 reason)); | 3929 reason)); |
3935 Isolate::Current()->long_jump_base()->Jump(1, error); | 3930 Isolate::Current()->long_jump_base()->Jump(1, error); |
3936 } | 3931 } |
3937 | 3932 |
3938 } // namespace dart | 3933 } // namespace dart |
OLD | NEW |