| 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 DEFINE_FLAG(bool, eliminate_type_checks, true, | 33 DEFINE_FLAG(bool, eliminate_type_checks, true, |
| 34 "Eliminate type checks when allowed by static type analysis."); | 34 "Eliminate type checks when allowed by static type analysis."); |
| 35 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); | 35 DEFINE_FLAG(bool, print_ast, false, "Print abstract syntax tree."); |
| 36 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); | 36 DEFINE_FLAG(bool, print_scopes, false, "Print scopes of local variables."); |
| 37 DEFINE_FLAG(bool, trace_type_check_elimination, false, | 37 DEFINE_FLAG(bool, trace_type_check_elimination, false, |
| 38 "Trace type check elimination at compile time."); | 38 "Trace type check elimination at compile time."); |
| 39 DECLARE_FLAG(bool, enable_type_checks); | 39 DECLARE_FLAG(bool, enable_type_checks); |
| 40 | 40 |
| 41 | 41 |
| 42 |
| 43 // TODO(srdjan): Allow compiler to add constants as they are encountered in |
| 44 // the compilation. |
| 45 const double kCommonDoubleConstants[] = |
| 46 {-1.0, -0.5, -0.1, 0.0, 0.1, 0.5, 1.0, 2.0, 4.0, 5.0, |
| 47 10.0, 20.0, 30.0, 64.0, 255.0, NAN, |
| 48 // From dart:math |
| 49 2.718281828459045, 2.302585092994046, 0.6931471805599453, |
| 50 1.4426950408889634, 0.4342944819032518, 3.1415926535897932, |
| 51 0.7071067811865476, 1.4142135623730951}; |
| 52 |
| 53 uword FlowGraphBuilder::FindDoubleConstant(double value) { |
| 54 intptr_t len = sizeof(kCommonDoubleConstants) / sizeof(double); // NOLINT |
| 55 for (intptr_t i = 0; i < len; i++) { |
| 56 // Bitwise compare. |
| 57 if (*reinterpret_cast<int64_t*>(&value) == |
| 58 *reinterpret_cast<const int64_t*>(&kCommonDoubleConstants[i])) { |
| 59 return reinterpret_cast<uword>(&kCommonDoubleConstants[i]); |
| 60 } |
| 61 } |
| 62 return 0; |
| 63 } |
| 64 |
| 65 |
| 42 // Base class for a stack of enclosing statements of interest (e.g., | 66 // Base class for a stack of enclosing statements of interest (e.g., |
| 43 // blocks (breakable) and loops (continuable)). | 67 // blocks (breakable) and loops (continuable)). |
| 44 class NestedStatement : public ValueObject { | 68 class NestedStatement : public ValueObject { |
| 45 public: | 69 public: |
| 46 FlowGraphBuilder* owner() const { return owner_; } | 70 FlowGraphBuilder* owner() const { return owner_; } |
| 47 const SourceLabel* label() const { return label_; } | 71 const SourceLabel* label() const { return label_; } |
| 48 NestedStatement* outer() const { return outer_; } | 72 NestedStatement* outer() const { return outer_; } |
| 49 JoinEntryInstr* break_target() const { return break_target_; } | 73 JoinEntryInstr* break_target() const { return break_target_; } |
| 50 | 74 |
| 51 virtual intptr_t ContextLevel() const; | 75 virtual intptr_t ContextLevel() const; |
| (...skipping 3847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3899 function.token_pos(), | 3923 function.token_pos(), |
| 3900 LanguageError::kError, | 3924 LanguageError::kError, |
| 3901 Heap::kNew, | 3925 Heap::kNew, |
| 3902 "FlowGraphBuilder Bailout: %s %s", | 3926 "FlowGraphBuilder Bailout: %s %s", |
| 3903 String::Handle(function.name()).ToCString(), | 3927 String::Handle(function.name()).ToCString(), |
| 3904 reason)); | 3928 reason)); |
| 3905 Isolate::Current()->long_jump_base()->Jump(1, error); | 3929 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3906 } | 3930 } |
| 3907 | 3931 |
| 3908 } // namespace dart | 3932 } // namespace dart |
| OLD | NEW |