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

Side by Side Diff: runtime/lib/identical.cc

Issue 340203003: Cleanup of error and warning reporting. (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | runtime/lib/object.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/code_patcher.h"
8 #include "vm/exceptions.h"
9 #include "vm/object.h" 7 #include "vm/object.h"
10 #include "vm/stack_frame.h" 8 #include "vm/report.h"
11 9
12 namespace dart { 10 namespace dart {
13 11
14 DECLARE_FLAG(bool, warn_on_javascript_compatibility); 12 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
15 13
16 static void JSWarning(const char* msg) {
17 DartFrameIterator iterator;
18 iterator.NextFrame(); // Skip native call.
19 StackFrame* caller_frame = iterator.NextFrame();
20 ASSERT(caller_frame != NULL);
21 const Code& caller_code = Code::Handle(caller_frame->LookupDartCode());
22 ASSERT(!caller_code.IsNull());
23 const uword caller_pc = caller_frame->pc();
24 // Assume an unoptimized static call. Optimization was prevented.
25 ICData& ic_data = ICData::Handle();
26 CodePatcher::GetUnoptimizedStaticCallAt(caller_pc, caller_code, &ic_data);
27 ASSERT(!ic_data.IsNull());
28 // Report warning only if not already reported at this location.
29 if (!ic_data.IssuedJSWarning()) {
30 ic_data.SetIssuedJSWarning();
31 Exceptions::JSWarning(caller_frame, "%s", msg);
32 }
33 }
34
35
36 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) { 14 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) {
37 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0)); 15 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0));
38 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1)); 16 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1));
39 const bool is_identical = a.IsIdenticalTo(b); 17 const bool is_identical = a.IsIdenticalTo(b);
18 const bool is_static_native = true; // Identical_comparison is static.
hausner 2014/06/18 21:48:53 ditto
regis 2014/06/18 22:13:27 Done.
40 if (FLAG_warn_on_javascript_compatibility) { 19 if (FLAG_warn_on_javascript_compatibility) {
41 if (!is_identical) { 20 if (!is_identical) {
42 if (a.IsString()) { 21 if (a.IsString()) {
43 if (String::Cast(a).Equals(b)) { 22 if (String::Cast(a).Equals(b)) {
44 JSWarning("strings that are equal are also identical"); 23 Report::JSWarningFromNative(is_static_native,
24 "strings that are equal are also identical");
45 } 25 }
46 } else if (a.IsInteger()) { 26 } else if (a.IsInteger()) {
47 if (b.IsDouble()) { 27 if (b.IsDouble()) {
48 const int64_t a_value = Integer::Cast(a).AsInt64Value(); 28 const int64_t a_value = Integer::Cast(a).AsInt64Value();
49 const double b_value = Double::Cast(b).value(); 29 const double b_value = Double::Cast(b).value();
50 if (a_value == floor(b_value)) { 30 if (a_value == floor(b_value)) {
51 JSWarning("integer value and integral double value that are equal " 31 Report::JSWarningFromNative(is_static_native,
52 "are also identical"); 32 "integer value and integral double value that are equal "
33 "are also identical");
53 } 34 }
54 } 35 }
55 } else if (a.IsDouble()) { 36 } else if (a.IsDouble()) {
56 if (b.IsInteger()) { 37 if (b.IsInteger()) {
57 const double a_value = Double::Cast(a).value(); 38 const double a_value = Double::Cast(a).value();
58 const int64_t b_value = Integer::Cast(b).AsInt64Value(); 39 const int64_t b_value = Integer::Cast(b).AsInt64Value();
59 if (floor(a_value) == b_value) { 40 if (floor(a_value) == b_value) {
60 JSWarning("integral double value and integer value that are equal " 41 Report::JSWarningFromNative(is_static_native,
61 "are also identical"); 42 "integral double value and integer value that are equal "
43 "are also identical");
62 } 44 }
63 } 45 }
64 } 46 }
65 } 47 }
66 } 48 }
67 return Bool::Get(is_identical).raw(); 49 return Bool::Get(is_identical).raw();
68 } 50 }
69 51
70 } // namespace dart 52 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object.cc » ('j') | runtime/lib/object.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698