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

Side by Side Diff: src/builtins.cc

Issue 1895643002: Revert of [Atomics] Remove Atomics code stubs; use TF ops (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 5130 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 { 5148 namespace {
5149 5149
5150 void ValidateSharedTypedArray(compiler::CodeStubAssembler* a, 5150 void ValidateSharedTypedArray(compiler::CodeStubAssembler* a,
5151 compiler::Node* tagged, compiler::Node* context, 5151 compiler::Node* tagged, compiler::Node* context) {
5152 compiler::Node** out_instance_type,
5153 compiler::Node** out_backing_store) {
5154 using namespace compiler; 5152 using namespace compiler;
5155 CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a), 5153 CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a),
5156 not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a), 5154 not_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a),
5157 not_float_or_clamped(a), invalid(a); 5155 not_float_or_clamped(a), invalid(a);
5158 5156
5159 // Fail if it is not a heap object. 5157 // Fail if it is not a heap object.
5160 a->Branch(a->WordIsSmi(tagged), &is_smi, &not_smi); 5158 a->Branch(a->WordIsSmi(tagged), &is_smi, &not_smi);
5161 a->Bind(&is_smi); 5159 a->Bind(&is_smi);
5162 a->Goto(&invalid); 5160 a->Goto(&invalid);
5163 5161
5164 // Fail if the array's instance type is not JSTypedArray. 5162 // Fail if the array's instance type is not JSTypedArray.
5165 a->Bind(&not_smi); 5163 a->Bind(&not_smi);
5166 a->Branch(a->WordEqual(a->LoadInstanceType(tagged), 5164 a->Branch(a->WordEqual(a->LoadInstanceType(tagged),
5167 a->Int32Constant(JS_TYPED_ARRAY_TYPE)), 5165 a->Int32Constant(JS_TYPED_ARRAY_TYPE)),
5168 &is_typed_array, &not_typed_array); 5166 &is_typed_array, &not_typed_array);
5169 a->Bind(&not_typed_array); 5167 a->Bind(&not_typed_array);
5170 a->Goto(&invalid); 5168 a->Goto(&invalid);
5171 5169
5172 // Fail if the array's JSArrayBuffer is not shared. 5170 // Fail if the array's JSArrayBuffer is not shared.
5173 a->Bind(&is_typed_array); 5171 a->Bind(&is_typed_array);
5174 Node* array_buffer = a->LoadObjectField(tagged, JSTypedArray::kBufferOffset); 5172 Node* is_buffer_shared =
5175 Node* is_buffer_shared = a->BitFieldDecode<JSArrayBuffer::IsShared>( 5173 a->BitFieldDecode<JSArrayBuffer::IsShared>(a->LoadObjectField(
5176 a->LoadObjectField(array_buffer, JSArrayBuffer::kBitFieldOffset)); 5174 a->LoadObjectField(tagged, JSTypedArray::kBufferOffset),
5175 JSArrayBuffer::kBitFieldOffset));
5177 a->Branch(is_buffer_shared, &is_shared, &not_shared); 5176 a->Branch(is_buffer_shared, &is_shared, &not_shared);
5178 a->Bind(&not_shared); 5177 a->Bind(&not_shared);
5179 a->Goto(&invalid); 5178 a->Goto(&invalid);
5180 5179
5181 // Fail if the array's element type is float32, float64 or clamped. 5180 // Fail if the array's element type is float32, float64 or clamped.
5182 a->Bind(&is_shared); 5181 a->Bind(&is_shared);
5183 Node* elements_instance_type = a->LoadInstanceType( 5182 Node* elements_instance_type = a->LoadInstanceType(
5184 a->LoadObjectField(tagged, JSObject::kElementsOffset)); 5183 a->LoadObjectField(tagged, JSObject::kElementsOffset));
5185 STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5184 STATIC_ASSERT(FIXED_INT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5186 STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5185 STATIC_ASSERT(FIXED_INT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5187 STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5186 STATIC_ASSERT(FIXED_INT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5188 STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5187 STATIC_ASSERT(FIXED_UINT8_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5189 STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5188 STATIC_ASSERT(FIXED_UINT16_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5190 STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE); 5189 STATIC_ASSERT(FIXED_UINT32_ARRAY_TYPE < FIXED_FLOAT32_ARRAY_TYPE);
5191 a->Branch(a->Int32LessThan(elements_instance_type, 5190 a->Branch(a->Int32LessThan(elements_instance_type,
5192 a->Int32Constant(FIXED_FLOAT32_ARRAY_TYPE)), 5191 a->Int32Constant(FIXED_FLOAT32_ARRAY_TYPE)),
5193 &not_float_or_clamped, &is_float_or_clamped); 5192 &not_float_or_clamped, &is_float_or_clamped);
5194 a->Bind(&is_float_or_clamped); 5193 a->Bind(&is_float_or_clamped);
5195 a->Goto(&invalid); 5194 a->Goto(&invalid);
5196 5195
5197 a->Bind(&invalid); 5196 a->Bind(&invalid);
5198 a->CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context, 5197 a->CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context,
5199 tagged); 5198 tagged);
5200 a->Return(a->UndefinedConstant()); 5199 a->Return(a->UndefinedConstant());
5201 5200
5202 a->Bind(&not_float_or_clamped); 5201 a->Bind(&not_float_or_clamped);
5203 *out_instance_type = elements_instance_type;
5204
5205 Node* backing_store =
5206 a->LoadObjectField(array_buffer, JSArrayBuffer::kBackingStoreOffset);
5207 Node* byte_offset = a->ChangeUint32ToWord(a->TruncateTaggedToWord32(
5208 context,
5209 a->LoadObjectField(tagged, JSArrayBufferView::kByteOffsetOffset)));
5210 *out_backing_store = a->IntPtrAdd(backing_store, byte_offset);
5211 } 5202 }
5212 5203
5213 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access 5204 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access
5214 compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a, 5205 compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a,
5215 compiler::Node* tagged, 5206 compiler::Node* tagged,
5216 compiler::Node* context) { 5207 compiler::Node* context) {
5217 using namespace compiler; 5208 using namespace compiler;
5218 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32); 5209 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32);
5219 5210
5220 Callable to_number = CodeFactory::ToNumber(a->isolate()); 5211 Callable to_number = CodeFactory::ToNumber(a->isolate());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
5267 a->Int32GreaterThanOrEqual(index_word, array_length_word)), 5258 a->Int32GreaterThanOrEqual(index_word, array_length_word)),
5268 &if_notinbounds, &if_inbounds); 5259 &if_notinbounds, &if_inbounds);
5269 a->Bind(&if_notinbounds); 5260 a->Bind(&if_notinbounds);
5270 a->Return( 5261 a->Return(
5271 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context)); 5262 a->CallRuntime(Runtime::kThrowInvalidAtomicAccessIndexError, context));
5272 a->Bind(&if_inbounds); 5263 a->Bind(&if_inbounds);
5273 } 5264 }
5274 5265
5275 } // anonymous namespace 5266 } // anonymous namespace
5276 5267
5277 void Builtins::Generate_AtomicsLoad(compiler::CodeStubAssembler* a) { 5268 void Builtins::Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* a) {
5278 using namespace compiler; 5269 using namespace compiler;
5270 Isolate* isolate = a->isolate();
5279 Node* array = a->Parameter(1); 5271 Node* array = a->Parameter(1);
5280 Node* index = a->Parameter(2); 5272 Node* index = a->Parameter(2);
5281 Node* context = a->Parameter(3 + 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);
5282 5279
5283 Node* instance_type; 5280 Callable atomics_load = CodeFactory::AtomicsLoad(isolate);
5284 Node* backing_store; 5281 Node* target = a->HeapConstant(atomics_load.code());
5285 ValidateSharedTypedArray(a, array, context, &instance_type, &backing_store); 5282 a->Return(a->CallStub(atomics_load.descriptor(), target, context, array,
5286 5283 index_word));
5287 Node* index_word32 = ConvertTaggedAtomicIndexToWord32(a, index, context);
5288 Node* array_length_word32 = a->TruncateTaggedToWord32(
5289 context, a->LoadObjectField(array, JSTypedArray::kLengthOffset));
5290 ValidateAtomicIndex(a, index_word32, array_length_word32, context);
5291 Node* index_word = a->ChangeUint32ToWord(index_word32);
5292
5293 CodeStubAssembler::Label i8(a), u8(a), i16(a), u16(a), i32(a), u32(a),
5294 other(a);
5295 int32_t case_values[] = {
5296 FIXED_INT8_ARRAY_TYPE, FIXED_UINT8_ARRAY_TYPE, FIXED_INT16_ARRAY_TYPE,
5297 FIXED_UINT16_ARRAY_TYPE, FIXED_INT32_ARRAY_TYPE, FIXED_UINT32_ARRAY_TYPE,
5298 };
5299 CodeStubAssembler::Label* case_labels[] = {
5300 &i8, &u8, &i16, &u16, &i32, &u32,
5301 };
5302 a->Switch(instance_type, &other, case_values, case_labels,
5303 arraysize(case_labels));
5304
5305 a->Bind(&i8);
5306 a->Return(
5307 a->SmiTag(a->AtomicLoad(MachineType::Int8(), backing_store, index_word)));
5308
5309 a->Bind(&u8);
5310 a->Return(a->SmiTag(
5311 a->AtomicLoad(MachineType::Uint8(), backing_store, index_word)));
5312
5313 a->Bind(&i16);
5314 a->Return(a->SmiTag(a->AtomicLoad(MachineType::Int16(), backing_store,
5315 a->WordShl(index_word, 1))));
5316
5317 a->Bind(&u16);
5318 a->Return(a->SmiTag(a->AtomicLoad(MachineType::Uint16(), backing_store,
5319 a->WordShl(index_word, 1))));
5320
5321 a->Bind(&i32);
5322 a->Return(a->ChangeInt32ToTagged(a->AtomicLoad(
5323 MachineType::Int32(), backing_store, a->WordShl(index_word, 2))));
5324
5325 a->Bind(&u32);
5326 a->Return(a->ChangeUint32ToTagged(a->AtomicLoad(
5327 MachineType::Uint32(), backing_store, a->WordShl(index_word, 2))));
5328
5329 // This shouldn't happen, we've already validated the type.
5330 a->Bind(&other);
5331 a->Return(a->Int32Constant(0));
5332 } 5284 }
5333 5285
5334 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ 5286 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \
5335 Handle<Code> Builtins::name() { \ 5287 Handle<Code> Builtins::name() { \
5336 Code** code_address = \ 5288 Code** code_address = \
5337 reinterpret_cast<Code**>(builtin_address(k##name)); \ 5289 reinterpret_cast<Code**>(builtin_address(k##name)); \
5338 return Handle<Code>(code_address); \ 5290 return Handle<Code>(code_address); \
5339 } 5291 }
5340 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ 5292 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
5341 Handle<Code> Builtins::name() { \ 5293 Handle<Code> Builtins::name() { \
(...skipping 17 matching lines...) Expand all
5359 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) 5311 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T)
5360 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 5312 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
5361 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 5313 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
5362 #undef DEFINE_BUILTIN_ACCESSOR_C 5314 #undef DEFINE_BUILTIN_ACCESSOR_C
5363 #undef DEFINE_BUILTIN_ACCESSOR_A 5315 #undef DEFINE_BUILTIN_ACCESSOR_A
5364 #undef DEFINE_BUILTIN_ACCESSOR_T 5316 #undef DEFINE_BUILTIN_ACCESSOR_T
5365 #undef DEFINE_BUILTIN_ACCESSOR_H 5317 #undef DEFINE_BUILTIN_ACCESSOR_H
5366 5318
5367 } // namespace internal 5319 } // namespace internal
5368 } // namespace v8 5320 } // 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