Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(375)

Unified Diff: src/extensions/free-buffer-extension.cc

Issue 85883002: Provide "freeBuffer()" primitive for testing under ASan. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Adding missng files Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/extensions/free-buffer-extension.cc
diff --git a/src/default-platform.cc b/src/extensions/free-buffer-extension.cc
similarity index 66%
copy from src/default-platform.cc
copy to src/extensions/free-buffer-extension.cc
index ef3c4ebd450bbc63ae99b4534a22fa5bd67a2f39..4040c90bffe4b2ac6f7088c267758cb5b81ca677 100644
--- a/src/default-platform.cc
+++ b/src/extensions/free-buffer-extension.cc
@@ -25,32 +25,35 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#include "free-buffer-extension.h"
+#include "platform.h"
#include "v8.h"
-#include "default-platform.h"
-
namespace v8 {
namespace internal {
-DefaultPlatform::DefaultPlatform() {}
-
+v8::Handle<v8::FunctionTemplate> FreeBufferExtension::GetNativeFunction(
+ v8::Handle<v8::String> str) {
+ return v8::FunctionTemplate::New(FreeBufferExtension::FreeBuffer);
+}
-DefaultPlatform::~DefaultPlatform() {}
-void DefaultPlatform::CallOnBackgroundThread(Task *task,
- ExpectedRuntime expected_runtime) {
- // TODO(jochen): implement.
- task->Run();
- delete task;
+void FreeBufferExtension::FreeBuffer(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ v8::Handle<v8::ArrayBuffer> arrayBuffer = args[0].As<v8::ArrayBuffer>();
+ v8::ArrayBuffer::Contents contents = arrayBuffer->Externalize();
+ V8::ArrayBufferAllocator()->Free(contents.Data(), contents.ByteLength());
}
-void DefaultPlatform::CallOnForegroundThread(v8::Isolate* isolate, Task* task) {
- // TODO(jochen): implement.
- task->Run();
- delete task;
-}
+void FreeBufferExtension::Register() {
+ static char buffer[100];
+ Vector<char> temp_vector(buffer, sizeof(buffer));
+ OS::SNPrintF(temp_vector, "native function freeBuffer();");
+ static FreeBufferExtension buffer_free_extension(buffer);
+ static v8::DeclareExtension declaration(&buffer_free_extension);
+}
} } // namespace v8::internal

Powered by Google App Engine
This is Rietveld 408576698