Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 29, 2024. It is now read-only.

Commit f8b7b9c

Browse files
committed
Remove deprecated and non-working script cache options, closes #99
1 parent 731c4bd commit f8b7b9c

File tree

6 files changed

+31
-529
lines changed

6 files changed

+31
-529
lines changed

‎scripts/test_v8/hello_world.cpp

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
using namespace v8;
88

9-
10-
void then_fnc(const FunctionCallbackInfo<Value>& info) {
11-
info.GetReturnValue().Set(42);
9+
void weak_callback(const v8::WeakCallbackInfo<v8::Persistent<v8::String>>& data) {
10+
printf("Weak callback called\n");
11+
data.GetParameter()->Reset();
12+
// data.GetIsolate()->AdjustAmountOfExternalAllocatedMemory(-(1024*1024*1024));
1213
}
1314

1415
int main(int argc, char* argv[]) {
1516
// Initialize V8.
17+
//v8::V8::InitializeICU();
18+
1619
std::unique_ptr<v8::Platform> platform = v8::platform::NewDefaultPlatform();
1720
v8::V8::InitializePlatform(platform.get());
1821

@@ -38,21 +41,32 @@ int main(int argc, char* argv[]) {
3841
// Enter the context for compiling and running the hello world script.
3942
Context::Scope context_scope(context);
4043

41-
Local<String> local_value = String::NewFromUtf8(isolate, "test");
4244

43-
v8::MaybeLocal<v8::Promise::Resolver> maybe_local_resolver = v8::Promise::Resolver::New(context);
44-
v8::Local<v8::Promise::Resolver> local_resolver = maybe_local_resolver.ToLocalChecked();
45+
test.Reset(isolate, String::NewFromUtf8(isolate, "Hello' + ', World!'"));
46+
test.SetWeak(&test, weak_callback, v8::WeakCallbackType::kParameter);
47+
// isolate->AdjustAmountOfExternalAllocatedMemory((1024*1024*1024));
48+
4549

46-
v8::Local<v8::Function> local_then = v8::Function::New(context, then_fnc).ToLocalChecked();
50+
// Create a string containing the JavaScript source code.
51+
// Local<String> source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' + hw");
52+
Local<String> source = String::NewFromUtf8(isolate, "(2+2*2) + ' ' + 'Hello' + ', World!'");
4753

48-
auto test1 = local_resolver->GetPromise()->Then(context, local_then).ToLocalChecked();
49-
auto test2 = test1->Then(context, local_then).ToLocalChecked();
50-
auto test3 = test2->Then(context, local_then).ToLocalChecked();
54+
// v8::Local<v8::String> hw = v8::Local<v8::String>::New(isolate, test);
55+
// context->Global()->Set(String::NewFromUtf8(isolate, "hw"), hw);
5156

52-
test2->Resolve(context, local_value);
53-
test3->Resolve(context, local_value);
57+
// Compile the source code.
58+
Local<Script> script = Script::Compile(source);
59+
60+
// Run the script to get the result.
61+
Local<Value> result = script->Run();
62+
63+
// Convert the result to an UTF8 string and print it.
64+
String::Utf8Value utf8(isolate, result);
65+
printf("%s\n", *utf8);
5466
}
5567

68+
isolate->LowMemoryNotification();
69+
5670

5771
// Dispose the isolate and tear down V8.
5872
isolate->Dispose();

‎src/php_v8_script_compiler.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,6 @@ PHP_MINIT_FUNCTION(php_v8_script_compiler)
349349
this_ce = zend_register_internal_class(&ce);
350350

351351
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_NO_COMPILE_OPTIONS"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kNoCompileOptions));
352-
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_PRODUCE_PARSER_CACHE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kProduceParserCache));
353-
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_CONSUME_PARSER_CACHE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kConsumeParserCache));
354-
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_PRODUCE_CODE_CACHE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kProduceCodeCache));
355-
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_PRODUCE_FULL_CODE_CACHE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kProduceFullCodeCache));
356352
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_CONSUME_CODE_CACHE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kConsumeCodeCache));
357353
zend_declare_class_constant_long(this_ce, ZEND_STRL("OPTION_EAGER_COMPILE"), static_cast<zend_long>(v8::ScriptCompiler::CompileOptions::kEagerCompile));
358354

‎stubs/src/ScriptCompiler.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@
2525
*/
2626
class ScriptCompiler
2727
{
28-
const OPTION_NO_COMPILE_OPTIONS = 0;
29-
const OPTION_PRODUCE_PARSER_CACHE = 1;
30-
const OPTION_CONSUME_PARSER_CACHE = 2;
31-
const OPTION_PRODUCE_CODE_CACHE = 3;
32-
const OPTION_PRODUCE_FULL_CODE_CACHE = 4;
33-
const OPTION_CONSUME_CODE_CACHE = 5;
34-
const OPTION_EAGER_COMPILE = 6;
28+
const OPTION_NO_COMPILE_OPTIONS = 0;
29+
const OPTION_CONSUME_CODE_CACHE = 5;
30+
const OPTION_EAGER_COMPILE = 6;
3531

3632
private function __construct()
3733
{

‎tests/001-verify_extension_entities.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,6 @@ class V8\ScriptCompiler\Source
406406

407407
class V8\ScriptCompiler
408408
const OPTION_NO_COMPILE_OPTIONS = 0
409-
const OPTION_PRODUCE_PARSER_CACHE = 1
410-
const OPTION_CONSUME_PARSER_CACHE = 2
411-
const OPTION_PRODUCE_CODE_CACHE = 3
412-
const OPTION_PRODUCE_FULL_CODE_CACHE = 4
413409
const OPTION_CONSUME_CODE_CACHE = 5
414410
const OPTION_EAGER_COMPILE = 6
415411
public static function getCachedDataVersionTag(): float

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /