| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/builtins.h" | 5 #include "src/builtins/builtins.h" |
| 6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 | 10 |
| 11 // ----------------------------------------------------------------------------- | 11 // ----------------------------------------------------------------------------- |
| 12 // ES6 section 21.1 ArrayBuffer Objects | 12 // ES6 section 21.1 ArrayBuffer Objects |
| 13 | 13 |
| 14 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Call]] case. | 14 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Call]] case. |
| 15 BUILTIN(ArrayBufferConstructor) { | 15 BUILTIN(ArrayBufferConstructor) { |
| 16 HandleScope scope(isolate); | 16 HandleScope scope(isolate); |
| 17 Handle<JSFunction> target = args.target<JSFunction>(); | 17 Handle<JSFunction> target = args.target(); |
| 18 DCHECK(*target == target->native_context()->array_buffer_fun() || | 18 DCHECK(*target == target->native_context()->array_buffer_fun() || |
| 19 *target == target->native_context()->shared_array_buffer_fun()); | 19 *target == target->native_context()->shared_array_buffer_fun()); |
| 20 THROW_NEW_ERROR_RETURN_FAILURE( | 20 THROW_NEW_ERROR_RETURN_FAILURE( |
| 21 isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, | 21 isolate, NewTypeError(MessageTemplate::kConstructorNotFunction, |
| 22 handle(target->shared()->name(), isolate))); | 22 handle(target->shared()->name(), isolate))); |
| 23 } | 23 } |
| 24 | 24 |
| 25 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Construct]] case. | 25 // ES6 section 24.1.2.1 ArrayBuffer ( length ) for the [[Construct]] case. |
| 26 BUILTIN(ArrayBufferConstructor_ConstructStub) { | 26 BUILTIN(ArrayBufferConstructor_ConstructStub) { |
| 27 HandleScope scope(isolate); | 27 HandleScope scope(isolate); |
| 28 Handle<JSFunction> target = args.target<JSFunction>(); | 28 Handle<JSFunction> target = args.target(); |
| 29 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); | 29 Handle<JSReceiver> new_target = Handle<JSReceiver>::cast(args.new_target()); |
| 30 Handle<Object> length = args.atOrUndefined(isolate, 1); | 30 Handle<Object> length = args.atOrUndefined(isolate, 1); |
| 31 DCHECK(*target == target->native_context()->array_buffer_fun() || | 31 DCHECK(*target == target->native_context()->array_buffer_fun() || |
| 32 *target == target->native_context()->shared_array_buffer_fun()); | 32 *target == target->native_context()->shared_array_buffer_fun()); |
| 33 Handle<Object> number_length; | 33 Handle<Object> number_length; |
| 34 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, number_length, | 34 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, number_length, |
| 35 Object::ToInteger(isolate, length)); | 35 Object::ToInteger(isolate, length)); |
| 36 if (number_length->Number() < 0.0) { | 36 if (number_length->Number() < 0.0) { |
| 37 THROW_NEW_ERROR_RETURN_FAILURE( | 37 THROW_NEW_ERROR_RETURN_FAILURE( |
| 38 isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); | 38 isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // ES6 section 24.1.3.1 ArrayBuffer.isView ( arg ) | 79 // ES6 section 24.1.3.1 ArrayBuffer.isView ( arg ) |
| 80 BUILTIN(ArrayBufferIsView) { | 80 BUILTIN(ArrayBufferIsView) { |
| 81 SealHandleScope shs(isolate); | 81 SealHandleScope shs(isolate); |
| 82 DCHECK_EQ(2, args.length()); | 82 DCHECK_EQ(2, args.length()); |
| 83 Object* arg = args[1]; | 83 Object* arg = args[1]; |
| 84 return isolate->heap()->ToBoolean(arg->IsJSArrayBufferView()); | 84 return isolate->heap()->ToBoolean(arg->IsJSArrayBufferView()); |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace internal | 87 } // namespace internal |
| 88 } // namespace v8 | 88 } // namespace v8 |
| OLD | NEW |