OLD | NEW |
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 | 5 |
6 // Defined when linking against shared lib on Windows. | 6 // Defined when linking against shared lib on Windows. |
7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) | 7 #if defined(USING_V8_SHARED) && !defined(V8_SHARED) |
8 #define V8_SHARED | 8 #define V8_SHARED |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 2059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 } | 2070 } |
2071 | 2071 |
2072 ArrayBuffer::Contents contents = array_buffer->IsExternal() | 2072 ArrayBuffer::Contents contents = array_buffer->IsExternal() |
2073 ? array_buffer->GetContents() | 2073 ? array_buffer->GetContents() |
2074 : array_buffer->Externalize(); | 2074 : array_buffer->Externalize(); |
2075 array_buffer->Neuter(); | 2075 array_buffer->Neuter(); |
2076 out_data->WriteArrayBufferContents(contents); | 2076 out_data->WriteArrayBufferContents(contents); |
2077 } else { | 2077 } else { |
2078 ArrayBuffer::Contents contents = array_buffer->GetContents(); | 2078 ArrayBuffer::Contents contents = array_buffer->GetContents(); |
2079 // Clone ArrayBuffer | 2079 // Clone ArrayBuffer |
2080 if (contents.ByteLength() > i::kMaxUInt32) { | 2080 if (contents.ByteLength() > i::kMaxInt) { |
2081 Throw(isolate, "ArrayBuffer is too big to clone"); | 2081 Throw(isolate, "ArrayBuffer is too big to clone"); |
2082 return false; | 2082 return false; |
2083 } | 2083 } |
2084 | 2084 |
2085 int byte_length = static_cast<int>(contents.ByteLength()); | 2085 int32_t byte_length = static_cast<int32_t>(contents.ByteLength()); |
2086 out_data->WriteTag(kSerializationTagArrayBuffer); | 2086 out_data->WriteTag(kSerializationTagArrayBuffer); |
2087 out_data->Write(byte_length); | 2087 out_data->Write(byte_length); |
2088 out_data->WriteMemory(contents.Data(), | 2088 out_data->WriteMemory(contents.Data(), byte_length); |
2089 static_cast<int>(contents.ByteLength())); | |
2090 } | 2089 } |
2091 } else if (value->IsSharedArrayBuffer()) { | 2090 } else if (value->IsSharedArrayBuffer()) { |
2092 Local<SharedArrayBuffer> sab = Local<SharedArrayBuffer>::Cast(value); | 2091 Local<SharedArrayBuffer> sab = Local<SharedArrayBuffer>::Cast(value); |
2093 if (FindInObjectList(sab, *seen_objects)) { | 2092 if (FindInObjectList(sab, *seen_objects)) { |
2094 Throw(isolate, "Duplicated shared array buffers not supported"); | 2093 Throw(isolate, "Duplicated shared array buffers not supported"); |
2095 return false; | 2094 return false; |
2096 } | 2095 } |
2097 seen_objects->Add(sab); | 2096 seen_objects->Add(sab); |
2098 if (!FindInObjectList(sab, to_transfer)) { | 2097 if (!FindInObjectList(sab, to_transfer)) { |
2099 Throw(isolate, "SharedArrayBuffer must be transferred"); | 2098 Throw(isolate, "SharedArrayBuffer must be transferred"); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2205 CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_name)); | 2204 CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_name)); |
2206 Local<Value> property_value; | 2205 Local<Value> property_value; |
2207 CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_value)); | 2206 CHECK(DeserializeValue(isolate, data, offset).ToLocal(&property_value)); |
2208 object->Set(isolate->GetCurrentContext(), property_name, property_value) | 2207 object->Set(isolate->GetCurrentContext(), property_name, property_value) |
2209 .FromJust(); | 2208 .FromJust(); |
2210 } | 2209 } |
2211 result = object; | 2210 result = object; |
2212 break; | 2211 break; |
2213 } | 2212 } |
2214 case kSerializationTagArrayBuffer: { | 2213 case kSerializationTagArrayBuffer: { |
2215 int byte_length = data.Read<int>(offset); | 2214 int32_t byte_length = data.Read<int32_t>(offset); |
2216 Local<ArrayBuffer> array_buffer = ArrayBuffer::New(isolate, byte_length); | 2215 Local<ArrayBuffer> array_buffer = ArrayBuffer::New(isolate, byte_length); |
2217 ArrayBuffer::Contents contents = array_buffer->GetContents(); | 2216 ArrayBuffer::Contents contents = array_buffer->GetContents(); |
2218 DCHECK(static_cast<size_t>(byte_length) == contents.ByteLength()); | 2217 DCHECK(static_cast<size_t>(byte_length) == contents.ByteLength()); |
2219 data.ReadMemory(contents.Data(), byte_length, offset); | 2218 data.ReadMemory(contents.Data(), byte_length, offset); |
2220 result = array_buffer; | 2219 result = array_buffer; |
2221 break; | 2220 break; |
2222 } | 2221 } |
2223 case kSerializationTagTransferredArrayBuffer: { | 2222 case kSerializationTagTransferredArrayBuffer: { |
2224 ArrayBuffer::Contents contents; | 2223 ArrayBuffer::Contents contents; |
2225 data.ReadArrayBufferContents(&contents, offset); | 2224 data.ReadArrayBufferContents(&contents, offset); |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2463 } | 2462 } |
2464 | 2463 |
2465 } // namespace v8 | 2464 } // namespace v8 |
2466 | 2465 |
2467 | 2466 |
2468 #ifndef GOOGLE3 | 2467 #ifndef GOOGLE3 |
2469 int main(int argc, char* argv[]) { | 2468 int main(int argc, char* argv[]) { |
2470 return v8::Shell::Main(argc, argv); | 2469 return v8::Shell::Main(argc, argv); |
2471 } | 2470 } |
2472 #endif | 2471 #endif |
OLD | NEW |