OLD | NEW |
---|---|
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 Loading... | |
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) { | |
5152 using namespace compiler; | 5153 using namespace compiler; |
5153 CodeStubAssembler::Label is_smi(a), not_smi(a), is_typed_array(a), | 5154 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_typed_array(a), is_shared(a), not_shared(a), is_float_or_clamped(a), |
5155 not_float_or_clamped(a), invalid(a); | 5156 not_float_or_clamped(a), invalid(a); |
5156 | 5157 |
5157 // Fail if it is not a heap object. | 5158 // Fail if it is not a heap object. |
5158 a->Branch(a->WordIsSmi(tagged), &is_smi, ¬_smi); | 5159 a->Branch(a->WordIsSmi(tagged), &is_smi, ¬_smi); |
5159 a->Bind(&is_smi); | 5160 a->Bind(&is_smi); |
5160 a->Goto(&invalid); | 5161 a->Goto(&invalid); |
5161 | 5162 |
(...skipping 30 matching lines...) Expand all Loading... | |
5192 ¬_float_or_clamped, &is_float_or_clamped); | 5193 ¬_float_or_clamped, &is_float_or_clamped); |
5193 a->Bind(&is_float_or_clamped); | 5194 a->Bind(&is_float_or_clamped); |
5194 a->Goto(&invalid); | 5195 a->Goto(&invalid); |
5195 | 5196 |
5196 a->Bind(&invalid); | 5197 a->Bind(&invalid); |
5197 a->CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context, | 5198 a->CallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, context, |
5198 tagged); | 5199 tagged); |
5199 a->Return(a->UndefinedConstant()); | 5200 a->Return(a->UndefinedConstant()); |
5200 | 5201 |
5201 a->Bind(¬_float_or_clamped); | 5202 a->Bind(¬_float_or_clamped); |
5203 *out_instance_type = elements_instance_type; | |
5204 } | |
5205 | |
5206 void BranchIfSharedTypedArrayIsSigned( | |
5207 compiler::CodeStubAssembler* a, compiler::Node* instance_type, | |
5208 compiler::CodeStubAssembler::Label* is_signed, | |
5209 compiler::CodeStubAssembler::Label* is_unsigned) { | |
5210 STATIC_ASSERT(((FIXED_INT8_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 0); | |
5211 STATIC_ASSERT(((FIXED_UINT8_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 1); | |
5212 STATIC_ASSERT(((FIXED_INT16_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 0); | |
5213 STATIC_ASSERT(((FIXED_UINT16_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 1); | |
5214 STATIC_ASSERT(((FIXED_INT32_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 0); | |
5215 STATIC_ASSERT(((FIXED_UINT32_ARRAY_TYPE - FIXED_INT8_ARRAY_TYPE) & 1) == 1); | |
5216 a->Branch(a->WordEqual( | |
5217 a->WordAnd(a->Int32Sub(instance_type, | |
5218 a->Int32Constant(FIXED_INT8_ARRAY_TYPE)), | |
5219 a->Int32Constant(1)), | |
5220 a->Int32Constant(0)), | |
5221 is_signed, is_unsigned); | |
5202 } | 5222 } |
5203 | 5223 |
5204 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access | 5224 // https://tc39.github.io/ecmascript_sharedmem/shmem.html#Atomics.ValidateAtomic Access |
5205 compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a, | 5225 compiler::Node* ConvertTaggedAtomicIndexToWord32(compiler::CodeStubAssembler* a, |
5206 compiler::Node* tagged, | 5226 compiler::Node* tagged, |
5207 compiler::Node* context) { | 5227 compiler::Node* context) { |
5208 using namespace compiler; | 5228 using namespace compiler; |
5209 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32); | 5229 CodeStubAssembler::Variable var_result(a, MachineRepresentation::kWord32); |
5210 | 5230 |
5211 Callable to_number = CodeFactory::ToNumber(a->isolate()); | 5231 Callable to_number = CodeFactory::ToNumber(a->isolate()); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5264 } | 5284 } |
5265 | 5285 |
5266 } // anonymous namespace | 5286 } // anonymous namespace |
5267 | 5287 |
5268 void Builtins::Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* a) { | 5288 void Builtins::Generate_AtomicsLoadCheck(compiler::CodeStubAssembler* a) { |
5269 using namespace compiler; | 5289 using namespace compiler; |
5270 Isolate* isolate = a->isolate(); | 5290 Isolate* isolate = a->isolate(); |
5271 Node* array = a->Parameter(1); | 5291 Node* array = a->Parameter(1); |
5272 Node* index = a->Parameter(2); | 5292 Node* index = a->Parameter(2); |
5273 Node* context = a->Parameter(3 + 2); | 5293 Node* context = a->Parameter(3 + 2); |
5274 ValidateSharedTypedArray(a, array, context); | 5294 Node* array_instance_type; |
5295 | |
5296 ValidateSharedTypedArray(a, array, context, &array_instance_type); | |
5275 Node* index_word = ConvertTaggedAtomicIndexToWord32(a, index, context); | 5297 Node* index_word = ConvertTaggedAtomicIndexToWord32(a, index, context); |
5276 Node* array_length_word = a->TruncateTaggedToWord32( | 5298 Node* array_length_word = a->TruncateTaggedToWord32( |
5277 context, a->LoadObjectField(array, JSTypedArray::kLengthOffset)); | 5299 context, a->LoadObjectField(array, JSTypedArray::kLengthOffset)); |
5278 ValidateAtomicIndex(a, index_word, array_length_word, context); | 5300 ValidateAtomicIndex(a, index_word, array_length_word, context); |
5279 | 5301 |
5280 Callable atomics_load = CodeFactory::AtomicsLoad(isolate); | 5302 Callable atomics_load = CodeFactory::AtomicsLoad(isolate); |
5281 Node* target = a->HeapConstant(atomics_load.code()); | 5303 Node* target = a->HeapConstant(atomics_load.code()); |
5282 a->Return(a->CallStub(atomics_load.descriptor(), target, context, array, | 5304 Node* untagged_result = a->CallStub(atomics_load.descriptor(), target, |
Benedikt Meurer
2016/04/14 04:16:20
I think this is not safe, because the CallInterfac
| |
5283 index_word)); | 5305 context, array, index_word); |
5306 | |
5307 CodeStubAssembler::Label is_signed(a), is_unsigned(a); | |
5308 BranchIfSharedTypedArrayIsSigned(a, array_instance_type, &is_signed, | |
5309 &is_unsigned); | |
5310 | |
5311 a->Bind(&is_signed); | |
5312 a->Return(a->ChangeInt32ToTagged(untagged_result)); | |
5313 | |
5314 a->Bind(&is_unsigned); | |
5315 a->Return(a->ChangeUint32ToTagged(untagged_result)); | |
5284 } | 5316 } |
5285 | 5317 |
5286 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ | 5318 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ |
5287 Handle<Code> Builtins::name() { \ | 5319 Handle<Code> Builtins::name() { \ |
5288 Code** code_address = \ | 5320 Code** code_address = \ |
5289 reinterpret_cast<Code**>(builtin_address(k##name)); \ | 5321 reinterpret_cast<Code**>(builtin_address(k##name)); \ |
5290 return Handle<Code>(code_address); \ | 5322 return Handle<Code>(code_address); \ |
5291 } | 5323 } |
5292 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ | 5324 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ |
5293 Handle<Code> Builtins::name() { \ | 5325 Handle<Code> Builtins::name() { \ |
(...skipping 17 matching lines...) Expand all Loading... | |
5311 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) | 5343 BUILTIN_LIST_T(DEFINE_BUILTIN_ACCESSOR_T) |
5312 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) | 5344 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) |
5313 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 5345 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
5314 #undef DEFINE_BUILTIN_ACCESSOR_C | 5346 #undef DEFINE_BUILTIN_ACCESSOR_C |
5315 #undef DEFINE_BUILTIN_ACCESSOR_A | 5347 #undef DEFINE_BUILTIN_ACCESSOR_A |
5316 #undef DEFINE_BUILTIN_ACCESSOR_T | 5348 #undef DEFINE_BUILTIN_ACCESSOR_T |
5317 #undef DEFINE_BUILTIN_ACCESSOR_H | 5349 #undef DEFINE_BUILTIN_ACCESSOR_H |
5318 | 5350 |
5319 } // namespace internal | 5351 } // namespace internal |
5320 } // namespace v8 | 5352 } // namespace v8 |
OLD | NEW |