Skip to content

Commit

Permalink
Remove custom memory allocation routines: We'll stick with the 4.4.9.…
Browse files Browse the repository at this point in the history
…1 of the v8 engine where this is not necessary since it appears to be much faster
  • Loading branch information
Martijn Otto committed Jul 14, 2015
1 parent 1de0e4d commit 0fc6220
Showing 1 changed file with 2 additions and 47 deletions.
49 changes: 2 additions & 47 deletions isolate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace JS {
/**
* Private class
*/
class Isolate final : private v8::ArrayBuffer::Allocator
class Isolate final
{
private:
/**
Expand All @@ -39,53 +39,11 @@ class Isolate final : private v8::ArrayBuffer::Allocator
*/
Platform _platform;

/**
* The isolate creation parameters
* @var v8::Isolate::CreateParams
*/
v8::Isolate::CreateParams _params;

/**
* The underlying isolate
* @var v8::Isolate*
*/
v8::Isolate *_isolate;

/**
* Allocate a range of memory, zero-initialized.
*
* @param size The number of bytes to allocate
* @return Pointer to the allocated memory, or a nullptr
*/
void *Allocate(size_t size) override
{
// request some cleared memory
return std::calloc(size, 1);
}

/**
* Allocate a range of memory, uninitialized.
*
* @param size The number of bytes to allocate
* @return Pointer to the allocated memory, or a nullptr
*/
void *AllocateUninitialized(size_t size) override
{
// request some uninitialized memory
return std::malloc(size);
}

/**
* Free some allocated memory
*
* @param data Pointer to memory to free
* @param size Number of bytes to free
*/
void Free(void *data, size_t size) override
{
// free the allocated memory
std::free(data);
}
public:
/**
* Constructor
Expand All @@ -97,11 +55,8 @@ class Isolate final : private v8::ArrayBuffer::Allocator
v8::V8::InitializePlatform(&_platform);
v8::V8::Initialize();

// initialize the parameters
_params.array_buffer_allocator = this;

// create the actual isolate
_isolate = v8::Isolate::New(_params);
_isolate = v8::Isolate::New();

// and enter it
_isolate->Enter();
Expand Down

0 comments on commit 0fc6220

Please sign in to comment.