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

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

Issue 312693008: Add javascript compatibility warnings for strings that are not identical, but (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/vm/dart_api_impl_test.cc » ('j') | no next file with comments »
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"
7 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/stack_frame.h"
8 11
9 namespace dart { 12 namespace dart {
10 13
14 DECLARE_FLAG(bool, warn_on_javascript_compatibility);
15
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
11 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) { 36 DEFINE_NATIVE_ENTRY(Identical_comparison, 2) {
12 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0)); 37 GET_NATIVE_ARGUMENT(Instance, a, arguments->NativeArgAt(0));
13 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1)); 38 GET_NATIVE_ARGUMENT(Instance, b, arguments->NativeArgAt(1));
14 return Bool::Get(a.IsIdenticalTo(b)).raw(); 39 const bool is_identical = a.IsIdenticalTo(b);
40 if (FLAG_warn_on_javascript_compatibility) {
41 if (!is_identical && a.IsString() && String::Cast(a).Equals(b)) {
42 JSWarning("strings that are equal are also identical");
43 }
44 }
45 return Bool::Get(is_identical).raw();
15 } 46 }
16 47
17 } // namespace dart 48 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698