| OLD | NEW | 
|     1 // Copyright 2012 the V8 project authors. All rights reserved. |     1 // Copyright 2012 the V8 project authors. All rights reserved. | 
|     2 // Redistribution and use in source and binary forms, with or without |     2 // Redistribution and use in source and binary forms, with or without | 
|     3 // modification, are permitted provided that the following conditions are |     3 // modification, are permitted provided that the following conditions are | 
|     4 // met: |     4 // met: | 
|     5 // |     5 // | 
|     6 //     * Redistributions of source code must retain the above copyright |     6 //     * Redistributions of source code must retain the above copyright | 
|     7 //       notice, this list of conditions and the following disclaimer. |     7 //       notice, this list of conditions and the following disclaimer. | 
|     8 //     * Redistributions in binary form must reproduce the above |     8 //     * Redistributions in binary form must reproduce the above | 
|     9 //       copyright notice, this list of conditions and the following |     9 //       copyright notice, this list of conditions and the following | 
|    10 //       disclaimer in the documentation and/or other materials provided |    10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 6001 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  6012   i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); |  6012   i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); | 
|  6013   EXCEPTION_PREAMBLE(isolate); |  6013   EXCEPTION_PREAMBLE(isolate); | 
|  6014   ENTER_V8(isolate); |  6014   ENTER_V8(isolate); | 
|  6015   i::Handle<i::JSObject> result = i::Copy(paragon_handle); |  6015   i::Handle<i::JSObject> result = i::Copy(paragon_handle); | 
|  6016   has_pending_exception = result.is_null(); |  6016   has_pending_exception = result.is_null(); | 
|  6017   EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); |  6017   EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); | 
|  6018   return Utils::ToLocal(result); |  6018   return Utils::ToLocal(result); | 
|  6019 } |  6019 } | 
|  6020  |  6020  | 
|  6021  |  6021  | 
 |  6022 bool v8::ArrayBuffer::IsExternal() const { | 
 |  6023   return Utils::OpenHandle(this)->is_external(); | 
 |  6024 } | 
 |  6025  | 
 |  6026 v8::ArrayBufferContents::~ArrayBufferContents() { | 
 |  6027   free(data_); | 
 |  6028   data_ = NULL; | 
 |  6029   byte_length_ = 0; | 
 |  6030 } | 
 |  6031  | 
 |  6032  | 
 |  6033 void v8::ArrayBuffer::Externalize(ArrayBufferContents* contents) { | 
 |  6034   i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 
 |  6035   ApiCheck(!obj->is_external(), | 
 |  6036             "v8::ArrayBuffer::Externalize", | 
 |  6037             "ArrayBuffer already externalized"); | 
 |  6038   obj->set_is_external(true); | 
 |  6039   size_t byte_length = static_cast<size_t>(obj->byte_length()->Number()); | 
 |  6040   ApiCheck(contents->data_ == NULL, | 
 |  6041            "v8::ArrayBuffer::Externalize", | 
 |  6042            "Externalizing into non-empty ArrayBufferContents"); | 
 |  6043   contents->data_ = obj->backing_store(); | 
 |  6044   contents->byte_length_ = byte_length; | 
 |  6045 } | 
 |  6046  | 
 |  6047  | 
|  6022 size_t v8::ArrayBuffer::ByteLength() const { |  6048 size_t v8::ArrayBuffer::ByteLength() const { | 
|  6023   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |  6049   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 
|  6024   if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0; |  6050   if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0; | 
|  6025   i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |  6051   i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); | 
|  6026   return static_cast<size_t>(obj->byte_length()->Number()); |  6052   return static_cast<size_t>(obj->byte_length()->Number()); | 
|  6027 } |  6053 } | 
|  6028  |  6054  | 
|  6029  |  6055  | 
|  6030 void* v8::ArrayBuffer::Data() const { |  | 
|  6031   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |  | 
|  6032   if (IsDeadCheck(isolate, "v8::ArrayBuffer::Data()")) return 0; |  | 
|  6033   i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this); |  | 
|  6034   return obj->backing_store(); |  | 
|  6035 } |  | 
|  6036  |  | 
|  6037  |  | 
|  6038 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { |  6056 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) { | 
|  6039   i::Isolate* isolate = i::Isolate::Current(); |  6057   i::Isolate* isolate = i::Isolate::Current(); | 
|  6040   EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); |  6058   EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)"); | 
|  6041   LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); |  6059   LOG_API(isolate, "v8::ArrayBuffer::New(size_t)"); | 
|  6042   ENTER_V8(isolate); |  6060   ENTER_V8(isolate); | 
|  6043   i::Handle<i::JSArrayBuffer> obj = |  6061   i::Handle<i::JSArrayBuffer> obj = | 
|  6044       isolate->factory()->NewJSArrayBuffer(); |  6062       isolate->factory()->NewJSArrayBuffer(); | 
|  6045   i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length); |  6063   i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length); | 
|  6046   return Utils::ToLocal(obj); |  6064   return Utils::ToLocal(obj); | 
|  6047 } |  6065 } | 
|  6048  |  6066  | 
|  6049  |  6067  | 
|  6050 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { |  6068 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) { | 
|  6051   i::Isolate* isolate = i::Isolate::Current(); |  6069   i::Isolate* isolate = i::Isolate::Current(); | 
|  6052   EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); |  6070   EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 
|  6053   LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); |  6071   LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)"); | 
|  6054   ENTER_V8(isolate); |  6072   ENTER_V8(isolate); | 
|  6055   i::Handle<i::JSArrayBuffer> obj = |  6073   i::Handle<i::JSArrayBuffer> obj = | 
|  6056       isolate->factory()->NewJSArrayBuffer(); |  6074       isolate->factory()->NewJSArrayBuffer(); | 
|  6057   i::Runtime::SetupArrayBuffer(isolate, obj, data, byte_length); |  6075   i::Runtime::SetupArrayBuffer(isolate, obj, true, data, byte_length); | 
|  6058   return Utils::ToLocal(obj); |  6076   return Utils::ToLocal(obj); | 
|  6059 } |  6077 } | 
|  6060  |  6078  | 
|  6061  |  6079  | 
|  6062 Local<ArrayBuffer> v8::TypedArray::Buffer() { |  6080 Local<ArrayBuffer> v8::TypedArray::Buffer() { | 
|  6063   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |  6081   i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 
|  6064   if (IsDeadCheck(isolate, "v8::TypedArray::Buffer()")) |  6082   if (IsDeadCheck(isolate, "v8::TypedArray::Buffer()")) | 
|  6065     return Local<ArrayBuffer>(); |  6083     return Local<ArrayBuffer>(); | 
|  6066   i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); |  6084   i::Handle<i::JSTypedArray> obj = Utils::OpenHandle(this); | 
|  6067   ASSERT(obj->buffer()->IsJSArrayBuffer()); |  6085   ASSERT(obj->buffer()->IsJSArrayBuffer()); | 
| (...skipping 1806 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  7874  |  7892  | 
|  7875   v->VisitPointers(blocks_.first(), first_block_limit_); |  7893   v->VisitPointers(blocks_.first(), first_block_limit_); | 
|  7876  |  7894  | 
|  7877   for (int i = 1; i < blocks_.length(); i++) { |  7895   for (int i = 1; i < blocks_.length(); i++) { | 
|  7878     v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |  7896     v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 
|  7879   } |  7897   } | 
|  7880 } |  7898 } | 
|  7881  |  7899  | 
|  7882  |  7900  | 
|  7883 } }  // namespace v8::internal |  7901 } }  // namespace v8::internal | 
| OLD | NEW |