Skip to content

Commit

Permalink
Builtins for sandbox profile serde
Browse files Browse the repository at this point in the history
Differential Revision: D64869470

fbshipit-source-id: dfb8571380c508766a2e7eca8a263c9dee288dd7
  • Loading branch information
arnabde03 authored and facebook-github-bot committed Nov 26, 2024
1 parent 2e66943 commit 5d05ff5
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hphp/hack/hhi/ext_sb_profile.hhi
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?hh

<<__PHPStdLib>>
function sb_profile_ser(string $sb_root, string $prof_path): string;
<<__PHPStdLib>>
function sb_profile_deser(string $sb_root, string $prof_path): string;
28 changes: 28 additions & 0 deletions hphp/runtime/ext/sb_profile/ext_sb_profile.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "hphp/runtime/ext/extension.h"
#include "hphp/runtime/vm/jit/prof-data-serialize.h"

namespace HPHP {

String HHVM_FUNCTION(sb_profile_ser,
const String& sb_root,
const String& prof_path) {
auto const status = jit::serializeSBProfData(sb_root.data(), prof_path.data());
return String{status.c_str()};
}

String HHVM_FUNCTION(sb_profile_deser,
const String& sb_root,
const String& prof_path) {
auto const status = jit::deserializeSBProfData(sb_root.data(), prof_path.data());
return String{status.c_str()};
}

static struct SbProfileExtension final : Extension {
SbProfileExtension()
: Extension("sb_profile", NO_EXTENSION_VERSION_YET, "hphp_hphpi") {}
void moduleRegisterNative() override {
HHVM_FE(sb_profile_ser);
HHVM_FE(sb_profile_deser);
}
} s_sb_profile_extension;
}
22 changes: 22 additions & 0 deletions hphp/runtime/ext/sb_profile/ext_sb_profile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?hh

/**
* Serializes sandbox profile. A profile can be serialized only once for the
* lifetime of the HHVM process.
*
* @param string $sb_root - PHP root directory of the sandbox.
* @param string $prof_path - Full path of the profile file.
* @return string - Status of the serialization attempt.
*/
<<__Native>>
function sb_profile_ser(string $sb_root, string $prof_path): string;
/**
* Deerializes sandbox profile. A profile can be deserialized only once for the
* lifetime of the HHVM process.
*
* @param string $sb_root - PHP root directory of the sandbox.
* @param string $prof_path - Full path of the profile file.
* @return string - Status of the deserialization attempt.
*/
<<__Native>>
function sb_profile_deser(string $sb_root, string $prof_path): string;

0 comments on commit 5d05ff5

Please sign in to comment.