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

Side by Side Diff: src/builtins/builtins-sharedarraybuffer.cc

Issue 2573573004: [stubs] Enable graph verification for builtins. (Closed)
Patch Set: Created 4 years 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/builtins/builtins-utils.h" 5 #include "src/builtins/builtins-utils.h"
6 #include "src/builtins/builtins.h" 6 #include "src/builtins/builtins.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/code-stub-assembler.h" 8 #include "src/code-stub-assembler.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 25 matching lines...) Expand all
36 not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a), 36 not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a),
37 not_float_or_clamped(a), invalid(a); 37 not_float_or_clamped(a), invalid(a);
38 38
39 // Fail if it is not a heap object. 39 // Fail if it is not a heap object.
40 a->Branch(a->TaggedIsSmi(tagged), &is_smi, &not_smi); 40 a->Branch(a->TaggedIsSmi(tagged), &is_smi, &not_smi);
41 a->Bind(&is_smi); 41 a->Bind(&is_smi);
42 a->Goto(&invalid); 42 a->Goto(&invalid);
43 43
44 // Fail if the array's instance type is not JSTypedArray. 44 // Fail if the array's instance type is not JSTypedArray.
45 a->Bind(&not_smi); 45 a->Bind(&not_smi);
46 a->Branch(a->WordEqual(a->LoadInstanceType(tagged), 46 a->Branch(a->Word32Equal(a->LoadInstanceType(tagged),
47 a->Int32Constant(JS_TYPED_ARRAY_TYPE)), 47 a->Int32Constant(JS_TYPED_ARRAY_TYPE)),
48 &is_typed_array, &not_typed_array); 48 &is_typed_array, &not_typed_array);
49 a->Bind(&not_typed_array); 49 a->Bind(&not_typed_array);
50 a->Goto(&invalid); 50 a->Goto(&invalid);
51 51
52 // Fail if the array's JSArrayBuffer is not shared. 52 // Fail if the array's JSArrayBuffer is not shared.
53 a->Bind(&is_typed_array); 53 a->Bind(&is_typed_array);
54 Node* array_buffer = a->LoadObjectField(tagged, JSTypedArray::kBufferOffset); 54 Node* array_buffer = a->LoadObjectField(tagged, JSTypedArray::kBufferOffset);
55 Node* is_buffer_shared = 55 Node* is_buffer_shared =
56 a->IsSetWord32<JSArrayBuffer::IsShared>(a->LoadObjectField( 56 a->IsSetWord32<JSArrayBuffer::IsShared>(a->LoadObjectField(
57 array_buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32())); 57 array_buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()));
(...skipping 23 matching lines...) Expand all
81 a->Return(a->UndefinedConstant()); 81 a->Return(a->UndefinedConstant());
82 82
83 a->Bind(&not_float_or_clamped); 83 a->Bind(&not_float_or_clamped);
84 *out_instance_type = elements_instance_type; 84 *out_instance_type = elements_instance_type;
85 85
86 Node* backing_store = 86 Node* backing_store =
87 a->LoadObjectField(array_buffer, JSArrayBuffer::kBackingStoreOffset); 87 a->LoadObjectField(array_buffer, JSArrayBuffer::kBackingStoreOffset);
88 Node* byte_offset = a->ChangeUint32ToWord(a->TruncateTaggedToWord32( 88 Node* byte_offset = a->ChangeUint32ToWord(a->TruncateTaggedToWord32(
89 context, 89 context,
90 a->LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset))); 90 a->LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset)));
91 *out_backing_store = a->IntPtrAdd(backing_store, byte_offset); 91 *out_backing_store =
92 a->IntPtrAdd(a->BitcastTaggedToWord(backing_store), byte_offset);
92 } 93 }
93 94
94 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access 95 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access
95 compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a, 96 compiler::Node* ConvertTaggedAtomicIndexToWord32(CodeStubAssembler* a,
96 compiler::Node* tagged, 97 compiler::Node* tagged,
97 compiler::Node* context) { 98 compiler::Node* context) {
98 using compiler::Node; 99 using compiler::Node;
99 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32); 100 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32);
100 101
101 Callable to_number = CodeFactory::ToNumber(a->isolate()); 102 Callable to_number = CodeFactory::ToNumber(a->isolate());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } 138 }
138 139
139 void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word, 140 void ValidateAtomicIndex(CodeStubAssembler* a, compiler::Node* index_word,
140 compiler::Node* array_length_word, 141 compiler::Node* array_length_word,
141 compiler::Node* context) { 142 compiler::Node* context) {
142 using compiler::Node; 143 using compiler::Node;
143 // Check if the index is in bounds. If not, throw RangeError. 144 // Check if the index is in bounds. If not, throw RangeError.
144 CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a); 145 CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a);
145 // TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length". 146 // TODO(jkummerow): Use unsigned comparison instead of "i<0 || i>length".
146 a->Branch( 147 a->Branch(
147 a->WordOr(a->Int32LessThan(index_word, a->Int32Constant(0)), 148 a->Word32Or(a->Int32LessThan(index_word, a->Int32Constant(0)),
148 a->Int32GreaterThanOrEqual(index_word, array_length_word)), 149 a->Int32GreaterThanOrEqual(index_word, array_length_word)),
149 &if_notinbounds, &if_inbounds); 150 &if_notinbounds, &if_inbounds);
150 a->Bind(&if_notinbounds); 151 a->Bind(&if_notinbounds);
151 a->Return( 152 a->Return(
152 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context)); 153 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context));
153 a->Bind(&if_inbounds); 154 a->Bind(&if_inbounds);
154 } 155 }
155 156
156 } // anonymous namespace 157 } // anonymous namespace
157 158
158 void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) { 159 void Builtins::Generate_AtomicsLoad(compiler::CodeAssemblerState* state) {
(...skipping 19 matching lines...) Expand all
178 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE, 179 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
179 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE, 180 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
180 }; 181 };
181 CodeStubAssembler::Label* case_labels[] = { 182 CodeStubAssembler::Label* case_labels[] = {
182 &i8, &u8, &i16, &u16, &i32, &u32, 183 &i8, &u8, &i16, &u16, &i32, &u32,
183 }; 184 };
184 a.Switch(instance_type, &other, case_values, case_labels, 185 a.Switch(instance_type, &other, case_values, case_labels,
185 arraysize(case_labels)); 186 arraysize(case_labels));
186 187
187 a.Bind(&i8); 188 a.Bind(&i8);
188 a.Return( 189 a.Return(a.SmiFromWord32(
189 a.SmiTag(a.AtomicLoad(MachineType::Int8(), backing_store, index_word))); 190 a.AtomicLoad(MachineType::Int8(), backing_store, index_word)));
190 191
191 a.Bind(&u8); 192 a.Bind(&u8);
192 a.Return( 193 a.Return(a.SmiFromWord32(
193 a.SmiTag(a.AtomicLoad(MachineType::Uint8(), backing_store, index_word))); 194 a.AtomicLoad(MachineType::Uint8(), backing_store, index_word)));
194 195
195 a.Bind(&i16); 196 a.Bind(&i16);
196 a.Return(a.SmiTag(a.AtomicLoad(MachineType::Int16(), backing_store, 197 a.Return(a.SmiFromWord32(a.AtomicLoad(MachineType::Int16(), backing_store,
197 a.WordShl(index_word, 1)))); 198 a.WordShl(index_word, 1))));
198 199
199 a.Bind(&u16); 200 a.Bind(&u16);
200 a.Return(a.SmiTag(a.AtomicLoad(MachineType::Uint16(), backing_store, 201 a.Return(a.SmiFromWord32(a.AtomicLoad(MachineType::Uint16(), backing_store,
201 a.WordShl(index_word, 1)))); 202 a.WordShl(index_word, 1))));
202 203
203 a.Bind(&i32); 204 a.Bind(&i32);
204 a.Return(a.ChangeInt32ToTagged(a.AtomicLoad( 205 a.Return(a.ChangeInt32ToTagged(a.AtomicLoad(
205 MachineType::Int32(), backing_store, a.WordShl(index_word, 2)))); 206 MachineType::Int32(), backing_store, a.WordShl(index_word, 2))));
206 207
207 a.Bind(&u32); 208 a.Bind(&u32);
208 a.Return(a.ChangeUint32ToTagged(a.AtomicLoad( 209 a.Return(a.ChangeUint32ToTagged(a.AtomicLoad(
209 MachineType::Uint32(), backing_store, a.WordShl(index_word, 2)))); 210 MachineType::Uint32(), backing_store, a.WordShl(index_word, 2))));
210 211
211 // This shouldn't happen, we've already validated the type. 212 // This shouldn't happen, we've already validated the type.
212 a.Bind(&other); 213 a.Bind(&other);
213 a.Return(a.Int32Constant(0)); 214 a.Return(a.SmiConstant(0));
214 } 215 }
215 216
216 void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) { 217 void Builtins::Generate_AtomicsStore(compiler::CodeAssemblerState* state) {
217 using compiler::Node; 218 using compiler::Node;
218 CodeStubAssembler a(state); 219 CodeStubAssembler a(state);
219 Node* array = a.Parameter(1); 220 Node* array = a.Parameter(1);
220 Node* index = a.Parameter(2); 221 Node* index = a.Parameter(2);
221 Node* value = a.Parameter(3); 222 Node* value = a.Parameter(3);
222 Node* context = a.Parameter(4 + 2); 223 Node* context = a.Parameter(4 + 2);
223 224
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 a.WordShl(index_word, 1), value_word32); 256 a.WordShl(index_word, 1), value_word32);
256 a.Return(value_integer); 257 a.Return(value_integer);
257 258
258 a.Bind(&u32); 259 a.Bind(&u32);
259 a.AtomicStore(MachineRepresentation::kWord32, backing_store, 260 a.AtomicStore(MachineRepresentation::kWord32, backing_store,
260 a.WordShl(index_word, 2), value_word32); 261 a.WordShl(index_word, 2), value_word32);
261 a.Return(value_integer); 262 a.Return(value_integer);
262 263
263 // This shouldn't happen, we've already validated the type. 264 // This shouldn't happen, we've already validated the type.
264 a.Bind(&other); 265 a.Bind(&other);
265 a.Return(a.Int32Constant(0)); 266 a.Return(a.SmiConstant(0));
266 } 267 }
267 268
268 } // namespace internal 269 } // namespace internal
269 } // namespace v8 270 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698