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

Side by Side Diff: src/builtins.cc

Issue 1884883003: Revert of [Atomics] code stubs for atomic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « src/builtins.h ('k') | src/code-factory.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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.h" 5 #include "src/builtins.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/api-arguments.h" 8 #include "src/api-arguments.h"
9 #include "src/api-natives.h" 9 #include "src/api-natives.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
(...skipping 5127 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 5138
5139 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) { 5139 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) {
5140 masm->TailCallRuntime(Runtime::kInterrupt); 5140 masm->TailCallRuntime(Runtime::kInterrupt);
5141 } 5141 }
5142 5142
5143 5143
5144 void Builtins::Generate_StackCheck(MacroAssembler* masm) { 5144 void Builtins::Generate_StackCheck(MacroAssembler* masm) {
5145 masm->TailCallRuntime(Runtime::kStackGuard); 5145 masm->TailCallRuntime(Runtime::kStackGuard);
5146 } 5146 }
5147 5147
5148 namespace {
5149
5150 void ValidateSharedTypedArray(compiler::CodeStubAssembler* a,
5151 compiler::Node* tagged, compiler::Node* context) {
5152 using namespace compiler;
5153 CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a),
5154 not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a),
5155 not_float_or_clamped(a), invalid(a);
5156
5157 // Fail if it is not a heap object.
5158 a->Branch(a->WordIsSmi(tagged), &is_smi, &not_smi);
5159 a->Bind(&is_smi);
5160 a->Goto(&invalid);
5161
5162 // Fail if the array's instance type is not JSTypedArray.
5163 a->Bind(&not_smi);
5164 a->Branch(a->WordEqual(a->LoadInstanceType(tagged),
5165 a->Int32Constant(JS_TYPED_ARRAY_TYPE)),
5166 &is_typed_array, &not_typed_array);
5167 a->Bind(&not_typed_array);
5168 a->Goto(&invalid);
5169
5170 // Fail if the array's JSArrayBuffer is not shared.
5171 a->Bind(&is_typed_array);
5172 Node* is_buffer_shared =
5173 a->BitFieldDecode<JSArrayBuffer::IsShared>(a->LoadObjectField(
5174 a->LoadObjectField(tagged, JSTypedArray::kBufferOffset),
5175 JSArrayBuffer::kBitFieldOffset));
5176 a->Branch(is_buffer_shared, &is_shared, &not_shared);
5177 a->Bind(&not_shared);
5178 a->Goto(&invalid);
5179
5180 // Fail if the array's element type is float32, float64 or clamped.
5181 a->Bind(&is_shared);
5182 Node* elements_instance_type = a->LoadInstanceType(
5183 a->LoadObjectField(tagged, JSObject::kElementsOffset));
5184 STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5185 STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5186 STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5187 STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5188 STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5189 STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5190 a->Branch(a->Int32LessThan(elements_instance_type,
5191 a->Int32Constant(FIXED_FLOAT32_ARRAY_TYPE)),
5192 &not_float_or_clamped, &is_float_or_clamped);
5193 a->Bind(&is_float_or_clamped);
5194 a->Goto(&invalid);
5195
5196 a->Bind(&invalid);
5197 a->CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context,
5198 tagged);
5199 a->Return(a->UndefinedConstant());
5200
5201 a->Bind(&not_float_or_clamped);
5202 }
5203
5204 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access
5205 compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a,
5206 compiler::Node* tagged,
5207 compiler::Node* context) {
5208 using namespace compiler;
5209 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32);
5210
5211 Callable to_number = CodeFactory::ToNumber(a->isolate());
5212 Node* number_index = a->CallStub(to_number, context, tagged);
5213 CodeStubAssembler::Label done(a, &var_result);
5214
5215 CodeStubAssembler::Label if_numberissmi(a), if_numberisnotsmi(a);
5216 a->Branch(a->WordIsSmi(number_index), &if_numberissmi, &if_numberisnotsmi);
5217
5218 a->Bind(&if_numberissmi);
5219 {
5220 var_result.Bind(a->SmiToWord32(number_index));
5221 a->Goto(&done);
5222 }
5223
5224 a->Bind(&if_numberisnotsmi);
5225 {
5226 Node* number_index_value = a->LoadHeapNumberValue(number_index);
5227 Node* access_index = a->TruncateFloat64ToInt32(number_index_value);
5228 Node* test_index = a->ChangeInt32ToFloat64(access_index);
5229
5230 CodeStubAssembler::Label if_indexesareequal(a), if_indexesarenotequal(a);
5231 a->Branch(a->Float64Equal(number_index_value, test_index),
5232 &if_indexesareequal, &if_indexesarenotequal);
5233
5234 a->Bind(&if_indexesareequal);
5235 {
5236 var_result.Bind(access_index);
5237 a->Goto(&done);
5238 }
5239
5240 a->Bind(&if_indexesarenotequal);
5241 a->Return(
5242 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context));
5243 }
5244
5245 a->Bind(&done);
5246 return var_result.value();
5247 }
5248
5249 void ValidateAtomicIndex(compiler::CodeStubAssembler* a,
5250 compiler::Node* index_word,
5251 compiler::Node* array_length_word,
5252 compiler::Node* context) {
5253 using namespace compiler;
5254 // Check if the index is in bounds. If not, throw RangeError.
5255 CodeStubAssembler::Label if_inbounds(a), if_notinbounds(a);
5256 a->Branch(
5257 a->WordOr(a->Int32LessThan(index_word, a->Int32Constant(0)),
5258 a->Int32GreaterThanOrEqual(index_word, array_length_word)),
5259 &if_notinbounds, &if_inbounds);
5260 a->Bind(&if_notinbounds);
5261 a->Return(
5262 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context));
5263 a->Bind(&if_inbounds);
5264 }
5265
5266 } // anonymous namespace
5267
5268 void Builtins::Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* a) {
5269 using namespace compiler;
5270 Isolate* isolate = a->isolate();
5271 Node* array = a->Parameter(1);
5272 Node* index = a->Parameter(2);
5273 Node* context = a->Parameter(3 + 2);
5274 ValidateSharedTypedArray(a, array, context);
5275 Node* index_word = ConvertTaggedAtomicIndexToWord32(a, index, context);
5276 Node* array_length_word = a->TruncateTaggedToWord32(
5277 context, a->LoadObjectField(array, JSTypedArray::kLengthOffset));
5278 ValidateAtomicIndex(a, index_word, array_length_word, context);
5279
5280 Callable atomics_load = CodeFactory::AtomicsLoad(isolate);
5281 Node* target = a->HeapConstant(atomics_load.code());
5282 a->Return(a->CallStub(atomics_load.descriptor(), target, context, array,
5283 index_word));
5284 }
5285 5148
5286 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ 5149 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \
5287 Handle<Code> Builtins::name() { \ 5150 Handle<Code> Builtins::name() { \
5288 Code** code_address = \ 5151 Code** code_address = \
5289 reinterpret_cast<Code**>(builtin_address(k##name)); \ 5152 reinterpret_cast<Code**>(builtin_address(k##name)); \
5290 return Handle<Code>(code_address); \ 5153 return Handle<Code>(code_address); \
5291 } 5154 }
5292 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ 5155 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
5293 Handle<Code> Builtins::name() { \ 5156 Handle<Code> Builtins::name() { \
5294 Code** code_address = \ 5157 Code** code_address = \
(...skipping 16 matching lines...) Expand all
5311 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5174 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5312 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5175 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5313 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5176 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5314 #undef DEFINE_BUILTIN_ACCESSOR_C 5177 #undef DEFINE_BUILTIN_ACCESSOR_C
5315 #undef DEFINE_BUILTIN_ACCESSOR_A 5178 #undef DEFINE_BUILTIN_ACCESSOR_A
5316 #undef DEFINE_BUILTIN_ACCESSOR_T 5179 #undef DEFINE_BUILTIN_ACCESSOR_T
5317 #undef DEFINE_BUILTIN_ACCESSOR_H 5180 #undef DEFINE_BUILTIN_ACCESSOR_H
5318 5181
5319 } // namespace internal 5182 } // namespace internal
5320 } // namespace v8 5183 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/code-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698