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

Side by Side Diff: src/builtins.cc

Issue 1617503003: [Atomics] code stubs for atomic operations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: more WIP on using CodeStubAssembler Created 4 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
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-natives.h" 8 #include "src/api-natives.h"
9 #include "src/arguments.h" 9 #include "src/arguments.h"
10 #include "src/base/once.h" 10 #include "src/base/once.h"
11 #include "src/bootstrapper.h" 11 #include "src/bootstrapper.h"
12 #include "src/compiler/code-stub-assembler.h"
12 #include "src/dateparser-inl.h" 13 #include "src/dateparser-inl.h"
13 #include "src/elements.h" 14 #include "src/elements.h"
14 #include "src/frames-inl.h" 15 #include "src/frames-inl.h"
15 #include "src/gdb-jit.h" 16 #include "src/gdb-jit.h"
16 #include "src/ic/handler-compiler.h" 17 #include "src/ic/handler-compiler.h"
17 #include "src/ic/ic.h" 18 #include "src/ic/ic.h"
18 #include "src/isolate-inl.h" 19 #include "src/isolate-inl.h"
19 #include "src/messages.h" 20 #include "src/messages.h"
20 #include "src/profiler/cpu-profiler.h" 21 #include "src/profiler/cpu-profiler.h"
21 #include "src/property-descriptor.h" 22 #include "src/property-descriptor.h"
(...skipping 4141 matching lines...) Expand 10 before | Expand all | Expand 10 after
4163 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) { 4164 void Builtins::Generate_InterruptCheck(MacroAssembler* masm) {
4164 masm->TailCallRuntime(Runtime::kInterrupt); 4165 masm->TailCallRuntime(Runtime::kInterrupt);
4165 } 4166 }
4166 4167
4167 4168
4168 void Builtins::Generate_StackCheck(MacroAssembler* masm) { 4169 void Builtins::Generate_StackCheck(MacroAssembler* masm) {
4169 masm->TailCallRuntime(Runtime::kStackGuard); 4170 masm->TailCallRuntime(Runtime::kStackGuard);
4170 } 4171 }
4171 4172
4172 4173
4174 void Builtins::Generate_AtomicsLoadCheck(MacroAssembler* masm) {
4175 using namespace compiler;
4176 Isolate* isolate = masm->isolate();
4177 Zone zone;
4178 CodeStubAssembler a(isolate, &zone, 2, Code::ComputeFlags(Code::STUB),
4179 "AtomicsLoadCheck");
4180
4181 Node* param0 = a.Parameter(0);
4182
4183 // Check if param0 is a heap object.
4184 CodeStubAssembler::Label is_heap_object, not_heap_object;
4185 a.Branch(a.IsHeapObject(param0), &is_heap_object, &not_heap_object);
4186 a.Bind(&not_heap_object);
4187 a.TailCallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, param0);
4188 a.Bind(&is_heap_object);
4189
4190 // Check if param0's instance type is JSTypedArray.
4191 CodeStubAssembler::Label is_typed_array, not_typed_array;
4192 a.Branch(
4193 a.WordEqual(a.InstanceType(param0), a.Int32Constant(JS_TYPED_ARRAY_TYPE)),
4194 &is_typed_array, &not_typed_array);
4195 a.Bind(&not_typed_array);
4196 a.TailCallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, param0);
4197 a.Bind(&is_typed_array);
4198
4199 // Check if param0's JSArrayBuffer is shared.
4200 CodeStubAssembler::Label is_shared, not_shared;
4201 Node* is_buffer_shared = a.BitFieldValue<JSArrayBuffer::IsShared>(
4202 a.LoadObjectField(a.LoadObjectField(param0, JSTypedArray::kBufferOffset),
4203 JSArrayBuffer::kBitFieldOffset));
4204 a.Branch(is_buffer_shared, &is_shared, &not_shared);
4205 a.Bind(&not_shared);
4206 a.TailCallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, param0);
4207 a.Bind(&is_shared);
4208
4209 // Check if param0's JSTypedArray element type is float32 or float64.
4210 CodeStubAssembler::Label is_float, not_float;
4211 Node* elements_instance_type =
4212 a.InstanceType(a.LoadObjectField(param0, JSObject::kElementsOffset));
4213 a.Branch(a.WordOr(a.WordEqual(elements_instance_type,
4214 a.Int32Constant(FIXED_FLOAT32_ARRAY_TYPE)),
4215 a.WordEqual(elements_instance_type,
4216 a.Int32Constant(FIXED_FLOAT64_ARRAY_TYPE))),
4217 &is_float, &not_float);
4218 a.Bind(&is_float);
4219 a.TailCallRuntime(Runtime::kThrowNotIntegerSharedTypedArrayError, param0);
4220 a.Bind(&not_float);
4221
4222 // Check if the index is in bounds. If not, return undefined.
4223 CodeStubAssembler::Label in_bounds, not_in_bounds;
4224 Node* param1_int =
4225 a.SmiUntag(a.CallRuntime(Runtime::kToInteger, a.Parameter(1)));
Jarin 2016/02/08 10:25:04 How do you know that ToInteger returns a Smi? You
4226 // TODO(binji): is length always a smi?
4227 Node* array_length =
4228 a.SmiUntag(a.LoadObjectField(param0, JSTypedArray::kLengthOffset));
Jarin 2016/02/08 10:25:04 Same here.
4229 a.Branch(a.WordOr(a.Int32LessThan(param1_int, a.Int32Constant(0)),
4230 a.Int32GreaterThanOrEqual(param1_int, array_length)),
4231 &not_in_bounds, &in_bounds);
4232 a.Bind(&not_in_bounds);
4233 a.Return(a.UndefinedConstant());
4234 a.Bind(&in_bounds);
4235
4236 a.Return(a.SmiTag(a.Int32Constant(42)));
4237
4238 masm->Jump(a.GenerateCode(), RelocInfo::CODE_TARGET);
4239 }
4240
4241
4173 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \ 4242 #define DEFINE_BUILTIN_ACCESSOR_C(name, ignore) \
4174 Handle<Code> Builtins::name() { \ 4243 Handle<Code> Builtins::name() { \
4175 Code** code_address = \ 4244 Code** code_address = \
4176 reinterpret_cast<Code**>(builtin_address(k##name)); \ 4245 reinterpret_cast<Code**>(builtin_address(k##name)); \
4177 return Handle<Code>(code_address); \ 4246 return Handle<Code>(code_address); \
4178 } 4247 }
4179 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \ 4248 #define DEFINE_BUILTIN_ACCESSOR_A(name, kind, state, extra) \
4180 Handle<Code> Builtins::name() { \ 4249 Handle<Code> Builtins::name() { \
4181 Code** code_address = \ 4250 Code** code_address = \
4182 reinterpret_cast<Code**>(builtin_address(k##name)); \ 4251 reinterpret_cast<Code**>(builtin_address(k##name)); \
4183 return Handle<Code>(code_address); \ 4252 return Handle<Code>(code_address); \
4184 } 4253 }
4185 #define DEFINE_BUILTIN_ACCESSOR_H(name, kind) \ 4254 #define DEFINE_BUILTIN_ACCESSOR_H(name, kind) \
4186 Handle<Code> Builtins::name() { \ 4255 Handle<Code> Builtins::name() { \
4187 Code** code_address = \ 4256 Code** code_address = \
4188 reinterpret_cast<Code**>(builtin_address(k##name)); \ 4257 reinterpret_cast<Code**>(builtin_address(k##name)); \
4189 return Handle<Code>(code_address); \ 4258 return Handle<Code>(code_address); \
4190 } 4259 }
4191 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) 4260 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C)
4192 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) 4261 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A)
4193 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H) 4262 BUILTIN_LIST_H(DEFINE_BUILTIN_ACCESSOR_H)
4194 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) 4263 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A)
4195 #undef DEFINE_BUILTIN_ACCESSOR_C 4264 #undef DEFINE_BUILTIN_ACCESSOR_C
4196 #undef DEFINE_BUILTIN_ACCESSOR_A 4265 #undef DEFINE_BUILTIN_ACCESSOR_A
4197 4266
4198 4267
4199 } // namespace internal 4268 } // namespace internal
4200 } // namespace v8 4269 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/code-factory.h » ('j') | src/compiler/code-stub-assembler.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698