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/api.h" | 5 #include "src/api.h" |
6 #include "src/api-natives.h" | 6 #include "src/api-natives.h" |
7 #include "src/assert-scope.h" | 7 #include "src/assert-scope.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/factory.h" | 10 #include "src/factory.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 namespace { | 30 namespace { |
31 struct RawBuffer { | 31 struct RawBuffer { |
32 const byte* start; | 32 const byte* start; |
33 const byte* end; | 33 const byte* end; |
34 size_t size() { return static_cast<size_t>(end - start); } | 34 size_t size() { return static_cast<size_t>(end - start); } |
35 }; | 35 }; |
36 | 36 |
37 | 37 |
38 RawBuffer GetRawBufferArgument( | 38 RawBuffer GetRawBufferArgument( |
39 ErrorThrower& thrower, const v8::FunctionCallbackInfo<v8::Value>& args) { | 39 ErrorThrower& thrower, const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 40 // TODO(titzer): allow typed array views. |
40 if (args.Length() < 1 || !args[0]->IsArrayBuffer()) { | 41 if (args.Length() < 1 || !args[0]->IsArrayBuffer()) { |
41 thrower.Error("Argument 0 must be an array buffer"); | 42 thrower.Error("Argument 0 must be an array buffer"); |
42 return {nullptr, nullptr}; | 43 return {nullptr, nullptr}; |
43 } | 44 } |
44 Local<ArrayBuffer> buffer = Local<ArrayBuffer>::Cast(args[0]); | 45 Local<ArrayBuffer> buffer = Local<ArrayBuffer>::Cast(args[0]); |
45 ArrayBuffer::Contents contents = buffer->GetContents(); | 46 ArrayBuffer::Contents contents = buffer->GetContents(); |
46 | 47 |
47 // TODO(titzer): allow offsets into buffers, views, etc. | |
48 | |
49 const byte* start = reinterpret_cast<const byte*>(contents.Data()); | 48 const byte* start = reinterpret_cast<const byte*>(contents.Data()); |
50 const byte* end = start + contents.ByteLength(); | 49 const byte* end = start + contents.ByteLength(); |
51 | 50 |
52 if (start == nullptr) { | 51 if (start == nullptr) { |
53 thrower.Error("ArrayBuffer argument is empty"); | 52 thrower.Error("ArrayBuffer argument is empty"); |
54 } | 53 } |
55 return {start, end}; | 54 return {start, end}; |
56 } | 55 } |
57 | 56 |
58 | 57 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) { | 323 if (!context->get(Context::WASM_FUNCTION_MAP_INDEX)->IsMap()) { |
325 Handle<Map> wasm_function_map = isolate->factory()->NewMap( | 324 Handle<Map> wasm_function_map = isolate->factory()->NewMap( |
326 JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize); | 325 JS_FUNCTION_TYPE, JSFunction::kSize + kPointerSize); |
327 wasm_function_map->set_is_callable(); | 326 wasm_function_map->set_is_callable(); |
328 context->set_wasm_function_map(*wasm_function_map); | 327 context->set_wasm_function_map(*wasm_function_map); |
329 } | 328 } |
330 } | 329 } |
331 | 330 |
332 } // namespace internal | 331 } // namespace internal |
333 } // namespace v8 | 332 } // namespace v8 |
OLD | NEW |