OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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/interpreter/interpreter-intrinsics.h" | 5 #include "src/interpreter/interpreter-intrinsics.h" |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 __ Abort(kWrongArgumentCountForInvokeIntrinsic); | 297 __ Abort(kWrongArgumentCountForInvokeIntrinsic); |
298 __ Goto(&arg_count_positive); | 298 __ Goto(&arg_count_positive); |
299 __ Bind(&arg_count_positive); | 299 __ Bind(&arg_count_positive); |
300 } | 300 } |
301 | 301 |
302 Node* result = __ CallJS(function, context, receiver_arg, target_args_count, | 302 Node* result = __ CallJS(function, context, receiver_arg, target_args_count, |
303 TailCallMode::kDisallow); | 303 TailCallMode::kDisallow); |
304 return result; | 304 return result; |
305 } | 305 } |
306 | 306 |
307 Node* IntrinsicsHelper::ValueOf(Node* args_reg, Node* arg_count, | |
308 Node* context) { | |
309 InterpreterAssembler::Variable return_value(assembler_, | |
310 MachineRepresentation::kTagged); | |
311 InterpreterAssembler::Label done(assembler_); | |
312 | |
313 Node* object = __ LoadRegister(args_reg); | |
314 return_value.Bind(object); | |
315 | |
316 // If the object is a smi return the object. | |
317 __ GotoIf(__ TaggedIsSmi(object), &done); | |
318 | |
319 // If the object is not a value type, return the object. | |
320 Node* condition = | |
321 CompareInstanceType(object, JS_VALUE_TYPE, kInstanceTypeEqual); | |
322 __ GotoUnless(condition, &done); | |
323 | |
324 // If the object is a value type, return the value field. | |
325 return_value.Bind(__ LoadObjectField(object, JSValue::kValueOffset)); | |
326 __ Goto(&done); | |
327 | |
328 __ Bind(&done); | |
329 return return_value.value(); | |
330 } | |
331 | |
332 Node* IntrinsicsHelper::ClassOf(Node* args_reg, Node* arg_count, | 307 Node* IntrinsicsHelper::ClassOf(Node* args_reg, Node* arg_count, |
333 Node* context) { | 308 Node* context) { |
334 Node* value = __ LoadRegister(args_reg); | 309 Node* value = __ LoadRegister(args_reg); |
335 return __ ClassOf(value); | 310 return __ ClassOf(value); |
336 } | 311 } |
337 | 312 |
338 void IntrinsicsHelper::AbortIfArgCountMismatch(int expected, Node* actual) { | 313 void IntrinsicsHelper::AbortIfArgCountMismatch(int expected, Node* actual) { |
339 InterpreterAssembler::Label match(assembler_); | 314 InterpreterAssembler::Label match(assembler_); |
340 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); | 315 Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected)); |
341 __ GotoIf(comparison, &match); | 316 __ GotoIf(comparison, &match); |
342 __ Abort(kWrongArgumentCountForInvokeIntrinsic); | 317 __ Abort(kWrongArgumentCountForInvokeIntrinsic); |
343 __ Goto(&match); | 318 __ Goto(&match); |
344 __ Bind(&match); | 319 __ Bind(&match); |
345 } | 320 } |
346 | 321 |
347 } // namespace interpreter | 322 } // namespace interpreter |
348 } // namespace internal | 323 } // namespace internal |
349 } // namespace v8 | 324 } // namespace v8 |
OLD | NEW |