当前位置: 首页 > news >正文

滁州市建设银行网站/廊坊seo快速排名

滁州市建设银行网站,廊坊seo快速排名,怎么做淘宝客个人网站,用eclipse做网站V8编译是个比较麻烦的事情,不仅是下载、编译的过程,不同系统、不同编译器、不同C版本都可能会出现不同的问题。之前编译的时候没有记录步骤,这次简单记录一下编译V8的过程,我的工作目录是/code/v8_code/。 1 编译V8 1 下载工具&…

V8编译是个比较麻烦的事情,不仅是下载、编译的过程,不同系统、不同编译器、不同C++版本都可能会出现不同的问题。之前编译的时候没有记录步骤,这次简单记录一下编译V8的过程,我的工作目录是/code/v8_code/。

1 编译V8

1 下载工具:git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
2 执行export PATH=$PATH:/code/v8_code/depot_tools,后续执行命令用到。
3 gclient config https://chromium.googlesource.com/v8/v8.git。
4 执行gclient sync (成功后当前目录下多一个v8目录,这时候有depot_tools和v8两个目录)
5 执行命令:alias gm=/code/v8_code/v8/tools/dev/gm.py,然后cd v8进入v8源码目录。
6 执行gm x64.release,编译成功,新建一个hello.js,执行out/x64.release/d8 hello.js就看到相应输出,或者执行out/x64.release/d8进入互动模式。

2 编译V8为静态库

执行alias v8gen=/code/v8_code/v8/tools/dev/v8gen.py,v8源码目录执行v8gen x64.release.sample生成配置文件,执行ninja -C out.gn/x64.release.sample v8_monolith编译静态库。

3 使用V8

我们可以在自己的项目里使用V8,这个已经有不少的例子,Node.js就是典型的例子,不过Node.js比较复杂,不利于快速理解如何使用V8,其实V8静态库和其他的静态库是一样,下面以V8的hello-world为例子,看看如何使用V8。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>#include "include/libplatform/libplatform.h"
#include "include/v8-context.h"
#include "include/v8-initialization.h"
#include "include/v8-isolate.h"
#include "include/v8-local-handle.h"
#include "include/v8-primitive.h"
#include "include/v8-script.h"int main(int argc, char* argv[]) {// Initialize V8.v8::V8::InitializeICUDefaultLocation(argv[0]);v8::V8::InitializeExternalStartupData(argv[0]);std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();v8::V8::InitializePlatform(platform.get());v8::V8::Initialize();// Create a new Isolate and make it the current one.v8::Isolate::CreateParams create_params;create_params.array_buffer_allocator =v8::ArrayBuffer::Allocator::NewDefaultAllocator();v8::Isolate* isolate = v8::Isolate::New(create_params);{v8::Isolate::Scope isolate_scope(isolate);// Create a stack-allocated handle scope.v8::HandleScope handle_scope(isolate);// Create a new context.v8::Local<v8::Context> context = v8::Context::New(isolate);// Enter the context for compiling and running the hello world script.v8::Context::Scope context_scope(context);{// Create a string containing the JavaScript source code.v8::Local<v8::String> source =v8::String::NewFromUtf8Literal(isolate, "'Hello' + ', World!'");// Compile the source code.v8::Local<v8::Script> script =v8::Script::Compile(context, source).ToLocalChecked();// Run the script to get the result.v8::Local<v8::Value> result = script->Run(context).ToLocalChecked();// Convert the result to an UTF8 string and print it.v8::String::Utf8Value utf8(isolate, result);printf("%s\n", *utf8);}const char csource[] = R"(let bytes = new Uint8Array([0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01,0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07,0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09, 0x01,0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b]);let module = new WebAssembly.Module(bytes);let instance = new WebAssembly.Instance(module);instance.exports.add(3, 4);)";// Create a string containing the JavaScript source code.v8::Local<v8::String> source =v8::String::NewFromUtf8Literal(isolate, csource);// Compile the source code.v8::Local<v8::Script> script =v8::Script::Compile(context, source).ToLocalChecked();// Run the script to get the result.v8::Local<v8::Value> result = script->Run(context).ToLocalChecked();// Convert the result to a uint32 and print it.uint32_t number = result->Uint32Value(context).ToChecked();printf("3 + 4 = %u\n", number);}}// Dispose the isolate and tear down V8.isolate->Dispose();v8::V8::Dispose();v8::V8::ShutdownPlatform();delete create_params.array_buffer_allocator;return 0;
}

V8的API使用过程就是初始化V8,编译执行脚本,销毁V8。下面执行g++ -I. -Iinclude samples/hello-world.cc -o hello_world -lv8_monolith -Lout.gn/x64.release.sample/obj/ -pthread -std=c++14 -DV8_COMPRESS_POINTERS编译hello-world,执行./hello_world,看到相应输出。基本的用法就是在把V8的头文件(include目录)和静态库复制到自己的项目里,然后在项目里#include<xxx/v8.h>就可以使用了,最后编译的时候类似编译hello-world一样,通过执行指定一些目录,就可以完成编译。可以参考https://github.com/theanarkh/No.js。

http://www.lbrq.cn/news/776701.html

相关文章:

  • 利用社交网站做淘宝客/全网推广平台有哪些
  • 商丘企业网站建设服务/山东最新消息今天
  • 优秀网站建设出售/搜索引擎seo如何优化
  • 亚马逊欧洲站/网页设计可以自学吗
  • 成都建设官方网站/游戏优化大师官网
  • 官网的网站设计公司/广州网站营销推广
  • 北京住房和城乡建设委员会网站电话/bing搜索
  • 导购类网站怎么做/济南seo网站排名优化工具
  • 怎么用 java做网站/互联网品牌的快速推广
  • 郑州做网站的公司/百度教育官网登录入口
  • 网站建设中单页源码/深圳电子网络推广查询
  • 收费网站怎么做/seo可以从哪些方面优化
  • 俄罗斯 日本/seo关键词是怎么优化的
  • 网站两侧固定广告代码/淘宝指数查询官网
  • 网站收录免费咨询/南京seo全网营销
  • 建设银行网银网站激活/百度小说排行榜2020
  • 深圳营销型网站公司电话/如何做营销推广
  • 体验比较好的网站/河北seo公司
  • wordpress 白色/北京企业网站seo平台
  • 湖南省网站备案时间/优化设计三年级上册答案
  • 深圳网站制作易捷网络/现在最火的推广平台有哪些
  • 温州外贸网站建设/外链网站是什么
  • 武汉平台网站建设 APP/网站营销网站营销推广
  • 鹤山网站建设/google收录提交入口
  • 宁波拾谷网站建设/微信推广链接怎么制作
  • wordpress建站打不开二级页面/简述优化搜索引擎的方法
  • 广州做网站的公司/最近爆发什么病毒感染
  • 怎么做网站音乐/软文推广是什么
  • 网站建设 网址导航/个人如何在百度上做广告
  • 谷歌优化seo/宁波seo搜索优化费用
  • Nginx 启用 HTTPS:阿里云免费 SSL 证书详细图文教程(新手0.5小时可完成)
  • 【KO】android 音视频
  • 电机极数2极、4极、6极、8极的区别
  • sqli-labs通关笔记-第44关 POST字符型堆叠注入(单引号闭合 手工注入+脚本注入3种方法)
  • Nestjs框架: RBAC基于角色的权限控制模型初探
  • 服务器硬件电路设计之 I2C 问答(三):I2C 总线上可以接多少个设备?如何保证数据的准确性?