Skip to content

Commit 9aa9c6c

Browse files
committed
V8 stub integration.
1 parent 22cb886 commit 9aa9c6c

File tree

8 files changed

+195
-57
lines changed

8 files changed

+195
-57
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,14 @@ if (HERA_V8)
6363
include(ProjectV8)
6464
endif()
6565

66-
if (NOT (HERA_BINARYEN OR HERA_WABT OR HERA_WAVM))
66+
if (NOT (HERA_BINARYEN OR HERA_WABT OR HERA_WAVM OR HERA_V8))
6767
message(FATAL_ERROR "At least one one engine must be enabled.")
6868
endif()
6969

7070
add_subdirectory(evmc)
7171
add_subdirectory(src)
7272
add_subdirectory(test)
7373

74-
7574
install(DIRECTORY include/hera DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
7675

7776
write_basic_package_version_file(heraConfigVersion.cmake COMPATIBILITY SameMajorVersion)

circle.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
defaults:
2+
install-deps-linux: &install-deps-linux
3+
run:
4+
name: "Installing dependencies"
5+
command: |
6+
sudo apt update && sudo apt install -y xz-utils bzip2 pkg-config
27
38
update-submodules: &update-submodules
49
run:
@@ -39,6 +44,7 @@ defaults:
3944
run:
4045
name: "Build"
4146
working_directory: ~/build
47+
no_output_timeout: 2h
4248
command: |
4349
cmake --build . --target package -- -j $BUILD_PARALLEL_JOBS
4450
mkdir -p ~/package
@@ -51,10 +57,10 @@ defaults:
5157
destination: package
5258

5359
add-package-to-workspace: &add-package-to-workspace
54-
persist_to_workspace:
55-
root: ~/package
56-
paths:
57-
- "*"
60+
persist_to_workspace:
61+
root: ~/package
62+
paths:
63+
- "*"
5864

5965
save-deps-cache: &save-deps-cache
6066
cache-save:
@@ -160,6 +166,16 @@ defaults:
160166
testeth --version
161167
testeth -t GeneralStateTests/stEWASMTests -- --testpath tests --vm ~/build/src/libhera.$SO --singlenet Byzantium --evmc engine=wavm $TESTETH_OPTIONS
162168
169+
test-v8: &test-v8
170+
run:
171+
name: "Test shared Hera (v8)"
172+
command: |
173+
export ASAN_OPTIONS=detect_leaks=0
174+
SO=$([ $(uname) = Darwin ] && echo dylib || echo so)
175+
if [[ $PRELOAD_ASAN ]]; then export LD_PRELOAD=/usr/lib/clang/8/lib/linux/libclang_rt.asan-x86_64.so; fi
176+
testeth --version
177+
testeth -t GeneralStateTests/stEWASMTests -- --testpath tests --vm ~/build/src/libhera.$SO --singlenet Byzantium --evmc engine=v8 $TESTETH_OPTIONS
178+
163179
evmc-test: &evmc-test
164180
run:
165181
name: "Run evmc tests"
@@ -194,13 +210,14 @@ jobs:
194210
BUILD_TYPE: Release
195211
CXX: clang++
196212
CC: clang
197-
GENERATOR: Ninja
213+
GENERATOR: Unix Makefiles
198214
BUILD_PARALLEL_JOBS: 4
199-
CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=OFF -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON -DEVMC_TEST_TOOLS=ON
215+
CMAKE_OPTIONS: -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=OFF -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON -DHERA_V8=ON -DEVMC_TEST_TOOLS=ON
200216
docker:
201217
- image: ethereum/cpp-build-env:9
202218
steps:
203219
- checkout
220+
- *install-deps-linux
204221
- *update-submodules
205222
- *environment-info
206223
- *restore-deps-cache
@@ -214,6 +231,7 @@ jobs:
214231
- *test-binaryen
215232
- *test-wabt
216233
- *test-wavm
234+
- *test-v8
217235
- *evmc-test
218236
- *evm2wasm-test
219237

@@ -222,15 +240,16 @@ jobs:
222240
BUILD_TYPE: Release
223241
CXX: clang++
224242
CC: clang
225-
GENERATOR: Ninja
243+
GENERATOR: Unix Makefiles
226244
BUILD_PARALLEL_JOBS: 4
227-
CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=OFF -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON -DEVMC_TEST_TOOLS=ON -DSANITIZE=address
245+
CMAKE_OPTIONS: -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=OFF -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON -DHERA_V8=ON -DEVMC_TEST_TOOLS=ON -DSANITIZE=address
228246
# The ASan must the first loaded shared library. Force preloading it with this flag.
229247
PRELOAD_ASAN: true
230248
docker:
231249
- image: ethereum/cpp-build-env:9
232250
steps:
233251
- checkout
252+
- *install-deps-linux
234253
- *update-submodules
235254
- *environment-info
236255
- *restore-deps-cache
@@ -243,6 +262,7 @@ jobs:
243262
- *test-binaryen
244263
- *test-wabt
245264
- *test-wavm
265+
- *test-v8
246266
- *evmc-test
247267
- *evm2wasm-test
248268

@@ -253,12 +273,13 @@ jobs:
253273
- CC: gcc
254274
- GENERATOR: Unix Makefiles
255275
- BUILD_PARALLEL_JOBS: 4
256-
- CMAKE_OPTIONS: -DCOVERAGE=ON -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_WAVM=ON
276+
- CMAKE_OPTIONS: -DCMAKE_VERBOSE_MAKEFILE=ON -DCOVERAGE=ON -DBUILD_SHARED_LIBS=ON -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_WAVM=ON -DHERA_V8=ON
257277
- TESTETH_OPTIONS: --evmc benchmark=true
258278
docker:
259279
- image: ethereum/cpp-build-env:9
260280
steps:
261281
- checkout
282+
- *install-deps-linux
262283
- *update-submodules
263284
- *environment-info
264285
- *restore-deps-cache
@@ -271,6 +292,7 @@ jobs:
271292
- *test-binaryen
272293
- *test-wabt
273294
- *test-wavm
295+
- *test-v8
274296
- *upload-coverage-data
275297

276298
linux-gcc-static-debug:
@@ -280,11 +302,12 @@ jobs:
280302
- CC: gcc
281303
- GENERATOR: Unix Makefiles
282304
- BUILD_PARALLEL_JOBS: 4
283-
- CMAKE_OPTIONS: -DBUILD_SHARED_LIBS=OFF -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON
305+
- CMAKE_OPTIONS: -DCMAKE_VERBOSE_MAKEFILE=ON -DBUILD_SHARED_LIBS=OFF -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WAVM=ON -DHERA_WABT=ON -DHERA_V8=ON
284306
docker:
285307
- image: ethereum/cpp-build-env:9
286308
steps:
287309
- checkout
310+
- *install-deps-linux
288311
- *update-submodules
289312
- *environment-info
290313
- *restore-deps-cache
@@ -299,7 +322,7 @@ jobs:
299322
- CXX: c++
300323
- GENERATOR: Unix Makefiles
301324
- BUILD_PARALLEL_JOBS: 4
302-
- CMAKE_OPTIONS: -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON
325+
- CMAKE_OPTIONS: -DCMAKE_VERBOSE_MAKEFILE=ON -DHERA_DEBUGGING=ON -DHERA_BINARYEN=ON -DHERA_WABT=ON -DHERA_V8=ON
303326
macos:
304327
xcode: "10.1.0"
305328
steps:
@@ -320,6 +343,7 @@ jobs:
320343
- *fetch-tests
321344
- *test-binaryen
322345
- *test-wabt
346+
- *test-v8
323347

324348
lint:
325349
docker:

cmake/ProjectV8.cmake

Lines changed: 44 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,61 @@
22
# based on https://github.com/aarlt/v8-cmake
33
#
44

5-
if(ProjectV8Included)
5+
if (ProjectV8Included)
66
return()
7-
endif()
7+
endif ()
88
set(ProjectV8Included TRUE)
99

1010
include(ExternalProject)
1111

12+
set(V8_LIBRARY ${CMAKE_BINARY_DIR}/deps/v8/out.gn/x64.release.sample/obj/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX})
13+
set(V8_INCLUDE ${CMAKE_BINARY_DIR}/deps/v8/include)
14+
1215
ExternalProject_Add(depot_tools
13-
GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools.git
14-
GIT_TAG bc23ca13f1b3b684d9c2a127f33b618a71644829
15-
SOURCE_DIR "${CMAKE_BINARY_DIR}/deps/depot_tools"
16-
CONFIGURE_COMMAND ""
17-
BUILD_COMMAND ""
18-
INSTALL_COMMAND ""
19-
TEST_COMMAND ""
20-
)
21-
if (NOT EXISTS "${CMAKE_BINARY_DIR}/deps/v8/BUILD.gn")
22-
ExternalProject_Add_Step(depot_tools fetch
23-
COMMAND ${CMAKE_SOURCE_DIR}/cmake/v8_wrap.sh ${CMAKE_BINARY_DIR}/deps/depot_tools fetch v8
24-
COMMENT "fetch v8"
25-
DEPENDEES install
26-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps"
27-
)
28-
else()
29-
ExternalProject_Add_Step(depot_tools fetch
30-
COMMAND ${CMAKE_SOURCE_DIR}/cmake/v8_wrap.sh ${CMAKE_BINARY_DIR}/deps/depot_tools gclient sync
31-
COMMENT "gclient sync"
16+
GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools.git
17+
GIT_TAG bc23ca13f1b3b684d9c2a127f33b618a71644829
18+
SOURCE_DIR "${CMAKE_BINARY_DIR}/deps/depot_tools"
19+
CONFIGURE_COMMAND ""
20+
BUILD_COMMAND ""
21+
INSTALL_COMMAND ""
22+
TEST_COMMAND ""
23+
BUILD_BYPRODUCTS "${V8_LIBRARY}"
24+
BUILD_BYPRODUCTS "${V8_INCLUDE}"
25+
)
26+
27+
ExternalProject_Add_Step(depot_tools fetch
28+
COMMAND ${CMAKE_SOURCE_DIR}/cmake/v8_fetch.sh ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
29+
COMMENT "v8: fetch"
3230
DEPENDEES install
33-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps/v8"
34-
)
35-
endif()
31+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps"
32+
)
3633

3734
ExternalProject_Add_Step(depot_tools v8gen
38-
COMMAND ${CMAKE_BINARY_DIR}/deps/v8/tools/dev/v8gen.py x64.release.sample
39-
COMMENT "v8gen.py x64.release.sample"
40-
DEPENDEES fetch
41-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps/v8"
42-
)
35+
COMMAND ${CMAKE_BINARY_DIR}/deps/v8/tools/dev/v8gen.py -vv x64.release.sample
36+
COMMENT "v8: v8gen.py x64.release.sample"
37+
DEPENDEES fetch
38+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps/v8"
39+
)
4340

4441
ExternalProject_Add_Step(depot_tools ninja
45-
COMMAND ${CMAKE_BINARY_DIR}/deps/depot_tools/ninja -C out.gn/x64.release.sample v8_monolith
46-
COMMENT "ninja -C out.gn/x64.release.sample v8_monolith"
47-
DEPENDEES v8gen
48-
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps/v8"
49-
)
42+
COMMAND ${CMAKE_BINARY_DIR}/deps/depot_tools/ninja -v -C out.gn/x64.release.sample v8_monolith
43+
COMMENT "v8: ninja -v -C out.gn/x64.release.sample v8_monolith"
44+
DEPENDEES v8gen
45+
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/deps/v8"
46+
)
5047

51-
add_library(v8 INTERFACE)
52-
add_library(v8:v8 ALIAS v8)
53-
add_dependencies(v8 v8lib depot_tools)
54-
target_include_directories(v8 INTERFACE
55-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/deps/v8/include>
56-
$<INSTALL_INTERFACE:include>
48+
add_library(v8::v8 STATIC IMPORTED)
49+
50+
set_target_properties(
51+
v8::v8
52+
PROPERTIES
53+
IMPORTED_CONFIGURATIONS Release
54+
IMPORTED_LOCATION_RELEASE ${V8_LIBRARY}
5755
)
58-
target_link_libraries(v8
59-
INTERFACE ${CMAKE_BINARY_DIR}/deps/v8/out.gn/x64.release.sample/obj/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX}
56+
file(MAKE_DIRECTORY ${V8_INCLUDE})
57+
target_include_directories(v8::v8 INTERFACE
58+
$<BUILD_INTERFACE:${V8_INCLUDE}>
59+
$<INSTALL_INTERFACE:include>
6060
)
61+
62+
add_dependencies(v8::v8 depot_tools)

cmake/v8_fetch.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
CMAKE_SOURCE_DIR=$1
3+
CMAKE_BINARY_DIR=$2
4+
if [ ! -f "${CMAKE_BINARY_DIR}/deps/v8/BUILD.gn" ]
5+
then
6+
rm -rf ${CMAKE_BINARY_DIR}/deps/v8
7+
${CMAKE_SOURCE_DIR}/cmake/v8_wrap.sh ${CMAKE_BINARY_DIR}/deps/depot_tools fetch v8
8+
else
9+
mkdir -p ${CMAKE_BINARY_DIR}/deps/v8/include
10+
${CMAKE_SOURCE_DIR}/cmake/v8_wrap.sh ${CMAKE_BINARY_DIR}/deps/depot_tools gclient sync
11+
fi

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ endif()
6666

6767
if(HERA_V8)
6868
target_compile_definitions(hera PRIVATE HERA_V8=1)
69-
target_link_libraries(hera PRIVATE v8:v8)
69+
target_link_libraries(hera PRIVATE v8::v8)
7070
endif()
7171

7272
install(TARGETS hera EXPORT heraTargets

src/hera.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
#if HERA_WABT
4040
#include "wabt.h"
4141
#endif
42+
#if HERA_V8
43+
#include "v8.h"
44+
#endif
4245

4346
#include <hera/buildinfo.h>
4447

@@ -71,7 +74,10 @@ const map<string, WasmEngineCreateFn> wasm_engine_map {
7174
{ "wavm", WavmEngine::create },
7275
#endif
7376
#if HERA_WABT
74-
{ "wabt", WabtEngine::create },
77+
{ "wabt", WabtEngine::create },
78+
#endif
79+
#if HERA_V8
80+
{ "v8", V8Engine::create },
7581
#endif
7682
};
7783

@@ -83,6 +89,8 @@ WasmEngineCreateFn wasmEngineCreateFn =
8389
WabtEngine::create
8490
#elif HERA_WAVM
8591
WavmEngine::create
92+
#elif HERA_V8
93+
V8Engine::create
8694
#else
8795
#error "No engine requested."
8896
#endif

src/v8.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2019 Alexander Arlt <alexander.arlt@arlt-labs.com>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include <iostream>
18+
19+
#include "v8.h"
20+
#include "debugging.h"
21+
#include "eei.h"
22+
#include "exceptions.h"
23+
24+
using namespace std;
25+
26+
namespace hera {
27+
28+
std::unique_ptr<WasmEngine> hera::V8Engine::create() {
29+
return nullptr;
30+
}
31+
32+
ExecutionResult hera::V8Engine::execute(evmc_context *context,
33+
bytes_view code,
34+
bytes_view state_code,
35+
const evmc_message &msg,
36+
bool meterInterfaceGas) {
37+
(void) context;
38+
(void) code;
39+
(void) state_code;
40+
(void) msg;
41+
(void) meterInterfaceGas;
42+
43+
ExecutionResult result{};
44+
return result;
45+
}
46+
47+
void hera::V8Engine::verifyContract(hera::bytes_view code) {
48+
(void) code;
49+
}
50+
51+
} // namespace hera

0 commit comments

Comments
 (0)