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

Unified Diff: runtime/vm/flow_graph_builder.cc

Issue 347873002: Ensure that a javascript compatibility warning results in a (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | tests/standalone/javascript_compatibility_errors_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/flow_graph_builder.cc
===================================================================
--- runtime/vm/flow_graph_builder.cc (revision 37514)
+++ runtime/vm/flow_graph_builder.cc (working copy)
@@ -41,9 +41,7 @@
DECLARE_FLAG(bool, enable_debugger);
DECLARE_FLAG(bool, enable_type_checks);
DECLARE_FLAG(int, optimization_counter_threshold);
-DECLARE_FLAG(bool, silent_warnings);
DECLARE_FLAG(bool, warn_on_javascript_compatibility);
-DECLARE_FLAG(bool, warning_as_error);
// Quick access to the locally defined isolate() method.
#define I (isolate())
@@ -1416,16 +1414,10 @@
}
-void FlowGraphBuilder::WarnOnJSIntegralNumTypeTest(
+bool FlowGraphBuilder::WarnOnJSIntegralNumTypeTest(
AstNode* node, const AbstractType& type) const {
- if (is_optimizing()) {
- // Warnings for constants are issued when the graph is built for the first
- // time only, i.e. just before generating unoptimized code.
- // They should not be repeated when generating optimized code.
- return;
- }
if (!(node->IsLiteralNode() && (type.IsIntType() || type.IsDoubleType()))) {
- return;
+ return false;
}
const Instance& instance = node->AsLiteralNode()->literal();
if (type.IsIntType()) {
@@ -1433,18 +1425,16 @@
const Double& double_instance = Double::Cast(instance);
double value = double_instance.value();
if (floor(value) == value) {
- JSWarning(node->token_pos(),
- "integral value of type 'double' is also considered "
- "to be of type 'int'");
+ return true;
}
}
} else {
ASSERT(type.IsDoubleType());
if (instance.IsInteger()) {
- JSWarning(node->token_pos(),
- "integer value is also considered to be of type 'double'");
+ return true;
}
}
+ return false;
}
@@ -1463,12 +1453,6 @@
ReturnDefinition(new ConstantInstr(Bool::Get(!negate_result)));
return;
}
-
- // Check for javascript compatibility.
- if (FLAG_warn_on_javascript_compatibility) {
- owner()->WarnOnJSIntegralNumTypeTest(node->left(), type);
- }
-
ValueGraphVisitor for_left_value(owner());
node->left()->Visit(&for_left_value);
Append(for_left_value);
@@ -1513,12 +1497,6 @@
ASSERT(!node->right()->AsTypeNode()->type().IsNull());
const AbstractType& type = node->right()->AsTypeNode()->type();
ASSERT(type.IsFinalized() && !type.IsMalformed() && !type.IsMalbounded());
-
- // Check for javascript compatibility.
- if (FLAG_warn_on_javascript_compatibility) {
- owner()->WarnOnJSIntegralNumTypeTest(node->left(), type);
- }
-
ValueGraphVisitor for_value(owner());
node->left()->Visit(&for_value);
Append(for_value);
@@ -1528,8 +1506,13 @@
for_value.value(),
type,
dst_name)) {
- ReturnValue(for_value.value());
- return;
+ // Check for javascript compatibility.
+ // Do not skip type check if javascript compatibility warning is required.
+ if (!FLAG_warn_on_javascript_compatibility ||
+ !owner()->WarnOnJSIntegralNumTypeTest(node->left(), type)) {
+ ReturnValue(for_value.value());
+ return;
+ }
}
PushArgumentInstr* push_left = PushArgument(for_value.value());
PushArgumentInstr* push_instantiator = NULL;
@@ -3960,20 +3943,6 @@
}
-void FlowGraphBuilder::JSWarning(intptr_t token_pos, const char* msg) const {
- const Script& script = Script::Handle(parsed_function_->function().script());
- if (FLAG_warning_as_error) {
- // Report::kJSWarning would result in a JavascriptCompatibilityError, but we
- // want a compile-time error.
- // TODO(regis): Should we change the expection and make the tests work with
- // a JavascriptCompatibilityError?
- Report::MessageF(Report::kWarning, script, token_pos, "%s", msg);
- UNREACHABLE();
- }
- Report::MessageF(Report::kJSWarning, script, token_pos, "%s", msg);
-}
-
-
void FlowGraphBuilder::Bailout(const char* reason) const {
const Function& function = parsed_function_->function();
Report::MessageF(Report::kBailout,
« no previous file with comments | « runtime/vm/flow_graph_builder.h ('k') | tests/standalone/javascript_compatibility_errors_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698