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

Side by Side Diff: runtime/vm/intrinsifier_mips.cc

Issue 883263004: Allows turning on checked mode on a per-isolate basis (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/globals.h" // Needed here to get TARGET_ARCH_MIPS. 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_MIPS.
6 #if defined(TARGET_ARCH_MIPS) 6 #if defined(TARGET_ARCH_MIPS)
7 7
8 #include "vm/intrinsifier.h" 8 #include "vm/intrinsifier.h"
9 9
10 #include "vm/assembler.h" 10 #include "vm/assembler.h"
11 #include "vm/dart_entry.h" 11 #include "vm/dart_entry.h"
12 #include "vm/flow_graph_compiler.h" 12 #include "vm/flow_graph_compiler.h"
13 #include "vm/object.h" 13 #include "vm/object.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/regexp_assembler.h" 15 #include "vm/regexp_assembler.h"
16 #include "vm/symbols.h" 16 #include "vm/symbols.h"
17 17
18 namespace dart { 18 namespace dart {
19 19
20 DECLARE_FLAG(bool, enable_type_checks); 20 DECLARE_FLAG(bool, enable_type_checks);
21 21
22 #define __ assembler-> 22 #define __ assembler->
23 23
24 24
25 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; } 25 intptr_t Intrinsifier::ParameterSlotFromSp() { return -1; }
26 26
27 27
28 static bool TypeChecksEnabled() {
29 return FLAG_enable_type_checks || Isolate::Current()->checked_mode();
30 }
31
32
28 static intptr_t ComputeObjectArrayTypeArgumentsOffset() { 33 static intptr_t ComputeObjectArrayTypeArgumentsOffset() {
29 const Library& core_lib = Library::Handle(Library::CoreLibrary()); 34 const Library& core_lib = Library::Handle(Library::CoreLibrary());
30 const Class& cls = Class::Handle( 35 const Class& cls = Class::Handle(
31 core_lib.LookupClassAllowPrivate(Symbols::_List())); 36 core_lib.LookupClassAllowPrivate(Symbols::_List()));
32 ASSERT(!cls.IsNull()); 37 ASSERT(!cls.IsNull());
33 ASSERT(cls.NumTypeArguments() == 1); 38 ASSERT(cls.NumTypeArguments() == 1);
34 const intptr_t field_offset = cls.type_arguments_field_offset(); 39 const intptr_t field_offset = cls.type_arguments_field_offset();
35 ASSERT(field_offset != Class::kNoTypeArguments); 40 ASSERT(field_offset != Class::kNoTypeArguments);
36 return field_offset; 41 return field_offset;
37 } 42 }
38 43
39 44
40 // Intrinsify only for Smi value and index. Non-smi values need a store buffer 45 // Intrinsify only for Smi value and index. Non-smi values need a store buffer
41 // update. Array length is always a Smi. 46 // update. Array length is always a Smi.
42 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) { 47 void Intrinsifier::ObjectArraySetIndexed(Assembler* assembler) {
43 Label fall_through; 48 Label fall_through;
44 49
45 if (FLAG_enable_type_checks) { 50 if (TypeChecksEnabled()) {
46 const intptr_t type_args_field_offset = 51 const intptr_t type_args_field_offset =
47 ComputeObjectArrayTypeArgumentsOffset(); 52 ComputeObjectArrayTypeArgumentsOffset();
48 // Inline simple tests (Smi, null), fallthrough if not positive. 53 // Inline simple tests (Smi, null), fallthrough if not positive.
49 Label checked_ok; 54 Label checked_ok;
50 __ lw(T2, Address(SP, 0 * kWordSize)); // Value. 55 __ lw(T2, Address(SP, 0 * kWordSize)); // Value.
51 56
52 // Null value is valid for any type. 57 // Null value is valid for any type.
53 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null())); 58 __ LoadImmediate(T7, reinterpret_cast<int32_t>(Object::null()));
54 __ beq(T2, T7, &checked_ok); 59 __ beq(T2, T7, &checked_ok);
55 60
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 137
133 __ Bind(&fall_through); 138 __ Bind(&fall_through);
134 } 139 }
135 140
136 141
137 // Add an element to growable array if it doesn't need to grow, otherwise 142 // Add an element to growable array if it doesn't need to grow, otherwise
138 // call into regular code. 143 // call into regular code.
139 // On stack: growable array (+1), value (+0). 144 // On stack: growable array (+1), value (+0).
140 void Intrinsifier::GrowableArray_add(Assembler* assembler) { 145 void Intrinsifier::GrowableArray_add(Assembler* assembler) {
141 // In checked mode we need to type-check the incoming argument. 146 // In checked mode we need to type-check the incoming argument.
142 if (FLAG_enable_type_checks) return; 147 if (TypeChecksEnabled()) return;
143 Label fall_through; 148 Label fall_through;
144 __ lw(T0, Address(SP, 1 * kWordSize)); // Array. 149 __ lw(T0, Address(SP, 1 * kWordSize)); // Array.
145 __ lw(T1, FieldAddress(T0, GrowableObjectArray::length_offset())); 150 __ lw(T1, FieldAddress(T0, GrowableObjectArray::length_offset()));
146 // T1: length. 151 // T1: length.
147 __ lw(T2, FieldAddress(T0, GrowableObjectArray::data_offset())); 152 __ lw(T2, FieldAddress(T0, GrowableObjectArray::data_offset()));
148 // T2: data. 153 // T2: data.
149 __ lw(T3, FieldAddress(T2, Array::length_offset())); 154 __ lw(T3, FieldAddress(T2, Array::length_offset()));
150 // Compare length with capacity. 155 // Compare length with capacity.
151 // T3: capacity. 156 // T3: capacity.
152 __ beq(T1, T3, &fall_through); // Must grow data. 157 __ beq(T1, T3, &fall_through); // Must grow data.
(...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 Isolate* isolate = Isolate::Current(); 2056 Isolate* isolate = Isolate::Current();
2052 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate)); 2057 __ LoadImmediate(V0, reinterpret_cast<uword>(isolate));
2053 // Set return value. 2058 // Set return value.
2054 __ Ret(); 2059 __ Ret();
2055 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset())); 2060 __ delay_slot()->lw(V0, Address(V0, Isolate::current_tag_offset()));
2056 } 2061 }
2057 2062
2058 } // namespace dart 2063 } // namespace dart
2059 2064
2060 #endif // defined TARGET_ARCH_MIPS 2065 #endif // defined TARGET_ARCH_MIPS
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698