Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
chakrashim,test: stub out serdes classes
Browse files Browse the repository at this point in the history
* Added stub shims for SharedArrayBuffer, ValueSerializer, and
  ValueDeserializer
* Disabled failing serdes tests
* Updated v8-version.h to match V8's version

PR-URL: #206
Reviewed-By: Kunal Pathak <[email protected]>
  • Loading branch information
kfarnung committed Mar 31, 2017
1 parent ff666e8 commit d1813bf
Show file tree
Hide file tree
Showing 7 changed files with 297 additions and 25 deletions.
3 changes: 3 additions & 0 deletions deps/chakrashim/chakrashim.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
'src/v8propertydescriptor.cc',
'src/v8proxy.cc',
'src/v8script.cc',
'src/v8sharedarraybuffer.cc',
'src/v8signature.cc',
'src/v8stacktrace.cc',
'src/v8string.cc',
Expand All @@ -131,6 +132,8 @@
'src/v8uint32.cc',
'src/v8v8.cc',
'src/v8value.cc',
'src/v8valueserializer.cc',
'src/v8valuedeserializer.cc',
],
}, # end chakrashim

Expand Down
27 changes: 2 additions & 25 deletions deps/chakrashim/include/v8-version.h
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
#define V8_INCLUDE_VERSION_H_
Expand Down
74 changes: 74 additions & 0 deletions deps/chakrashim/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -1913,6 +1913,80 @@ class V8_EXPORT Float64Array : public TypedArray {
Float64Array();
};

class V8_EXPORT SharedArrayBuffer : public Object {
public:
V8_INLINE static SharedArrayBuffer* Cast(Value* obj);

private:
SharedArrayBuffer();
};

class V8_EXPORT ValueSerializer {
public:
class V8_EXPORT Delegate {
public:
virtual ~Delegate() {}

virtual void ThrowDataCloneError(Local<String> message) = 0;
virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object);
virtual Maybe<uint32_t> GetSharedArrayBufferId(
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer);
virtual void* ReallocateBufferMemory(void* old_buffer, size_t size,
size_t* actual_size);
virtual void FreeBufferMemory(void* buffer);
};

explicit ValueSerializer(Isolate* isolate);
ValueSerializer(Isolate* isolate, Delegate* delegate);
~ValueSerializer();

void WriteHeader();
V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context,
Local<Value> value);
V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release();
void TransferArrayBuffer(uint32_t transfer_id,
Local<ArrayBuffer> array_buffer);
void SetTreatArrayBufferViewsAsHostObjects(bool mode);
void WriteUint32(uint32_t value);
void WriteUint64(uint64_t value);
void WriteDouble(double value);
void WriteRawBytes(const void* source, size_t length);

private:
ValueSerializer(const ValueSerializer&) = delete;
void operator=(const ValueSerializer&) = delete;
};

class V8_EXPORT ValueDeserializer {
public:
class V8_EXPORT Delegate {
public:
virtual ~Delegate() {}

virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate);
};

ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size,
Delegate* delegate);
~ValueDeserializer();

V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context);
V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context);
void TransferArrayBuffer(uint32_t transfer_id,
Local<ArrayBuffer> array_buffer);
void TransferSharedArrayBuffer(uint32_t id,
Local<SharedArrayBuffer> shared_array_buffer);
uint32_t GetWireFormatVersion() const;
V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value);
V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value);
V8_WARN_UNUSED_RESULT bool ReadDouble(double* value);
V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data);

private:
ValueDeserializer(const ValueDeserializer&) = delete;
void operator=(const ValueDeserializer&) = delete;
};

enum AccessType {
ACCESS_GET,
ACCESS_SET,
Expand Down
30 changes: 30 additions & 0 deletions deps/chakrashim/src/v8sharedarraybuffer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright Microsoft. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

#include "v8chakra.h"

namespace v8 {

SharedArrayBuffer* SharedArrayBuffer::Cast(Value* obj) {
CHAKRA_UNIMPLEMENTED();
return nullptr;
}

} // namespace v8
86 changes: 86 additions & 0 deletions deps/chakrashim/src/v8valuedeserializer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright Microsoft. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

#include "v8chakra.h"

namespace v8 {

MaybeLocal<Object> ValueDeserializer::Delegate::ReadHostObject(
Isolate* isolate) {
CHAKRA_UNIMPLEMENTED();
return Local<Object>();
}

ValueDeserializer::ValueDeserializer(Isolate* isolate, const uint8_t* data,
size_t size, Delegate* delegate) {
CHAKRA_UNIMPLEMENTED();
}

ValueDeserializer::~ValueDeserializer() {
CHAKRA_UNIMPLEMENTED();
}

Maybe<bool> ValueDeserializer::ReadHeader(Local<Context> context) {
CHAKRA_UNIMPLEMENTED();
return Nothing<bool>();
}

MaybeLocal<Value> ValueDeserializer::ReadValue(Local<Context> context) {
CHAKRA_UNIMPLEMENTED();
return Local<Value>();
}


void ValueDeserializer::TransferArrayBuffer(uint32_t transfer_id,
Local<ArrayBuffer> array_buffer) {
CHAKRA_UNIMPLEMENTED();
}

void ValueDeserializer::TransferSharedArrayBuffer(
uint32_t id, Local<SharedArrayBuffer> shared_array_buffer) {
CHAKRA_UNIMPLEMENTED();
}

uint32_t ValueDeserializer::GetWireFormatVersion() const {
CHAKRA_UNIMPLEMENTED();
return 0;
}

bool ValueDeserializer::ReadUint32(uint32_t* value) {
CHAKRA_UNIMPLEMENTED();
return false;
}

bool ValueDeserializer::ReadUint64(uint64_t* value) {
CHAKRA_UNIMPLEMENTED();
return false;
}

bool ValueDeserializer::ReadDouble(double* value) {
CHAKRA_UNIMPLEMENTED();
return false;
}

bool ValueDeserializer::ReadRawBytes(size_t length, const void** data) {
CHAKRA_UNIMPLEMENTED();
return false;
}

} // namespace v8
100 changes: 100 additions & 0 deletions deps/chakrashim/src/v8valueserializer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// Copyright Microsoft. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files(the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and / or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions :
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

#include "v8chakra.h"

namespace v8 {

Maybe<bool> ValueSerializer::Delegate::WriteHostObject(Isolate* isolate,
Local<Object> object) {
CHAKRA_UNIMPLEMENTED();
return Nothing<bool>();
}

Maybe<uint32_t> ValueSerializer::Delegate::GetSharedArrayBufferId(
Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer) {
CHAKRA_UNIMPLEMENTED();
return Nothing<unsigned int>();
}

void* ValueSerializer::Delegate::ReallocateBufferMemory(void* old_buffer,
size_t size,
size_t* actual_size) {
CHAKRA_UNIMPLEMENTED();
return nullptr;
}

void ValueSerializer::Delegate::FreeBufferMemory(void* buffer) {
CHAKRA_UNIMPLEMENTED();
}

ValueSerializer::ValueSerializer(Isolate* isolate) {
CHAKRA_UNIMPLEMENTED();
}

ValueSerializer::ValueSerializer(Isolate* isolate, Delegate* delegate) {
CHAKRA_UNIMPLEMENTED();
}

ValueSerializer::~ValueSerializer() {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::WriteHeader() {
CHAKRA_UNIMPLEMENTED();
}

Maybe<bool> ValueSerializer::WriteValue(Local<Context> context,
Local<Value> value) {
CHAKRA_UNIMPLEMENTED();
return Nothing<bool>();
}

std::pair<uint8_t*, size_t> ValueSerializer::Release() {
CHAKRA_UNIMPLEMENTED();
return std::pair<uint8_t*, size_t>();
}

void ValueSerializer::TransferArrayBuffer(uint32_t transfer_id,
Local<ArrayBuffer> array_buffer) {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::SetTreatArrayBufferViewsAsHostObjects(bool mode) {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::WriteUint32(uint32_t value) {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::WriteUint64(uint64_t value) {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::WriteDouble(double value) {
CHAKRA_UNIMPLEMENTED();
}

void ValueSerializer::WriteRawBytes(const void* source, size_t length) {
CHAKRA_UNIMPLEMENTED();
}

} // namespace v8
2 changes: 2 additions & 0 deletions test/parallel/parallel.status
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ test-trace-event : SKIP
test-util-inspect-proxy : SKIP
test-util-inspect-simd : SKIP
test-url-domain-ascii-unicode : SKIP
test-v8-serdes : SKIP
test-v8-serdes-sharedarraybuffer : SKIP
test-vm-cached-data : SKIP
test-vm-context : SKIP
test-vm-create-and-run-in-context : SKIP
Expand Down

0 comments on commit d1813bf

Please sign in to comment.