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

Side by Side Diff: src/api.cc

Issue 13958007: First cut at API for ES6 ArrayBuffers (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: CR feedback Created 7 years, 7 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/api.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "heap-snapshot-generator-inl.h" 45 #include "heap-snapshot-generator-inl.h"
46 #include "messages.h" 46 #include "messages.h"
47 #ifdef COMPRESS_STARTUP_DATA_BZ2 47 #ifdef COMPRESS_STARTUP_DATA_BZ2
48 #include "natives.h" 48 #include "natives.h"
49 #endif 49 #endif
50 #include "parser.h" 50 #include "parser.h"
51 #include "platform.h" 51 #include "platform.h"
52 #include "profile-generator-inl.h" 52 #include "profile-generator-inl.h"
53 #include "property-details.h" 53 #include "property-details.h"
54 #include "property.h" 54 #include "property.h"
55 #include "runtime.h"
55 #include "runtime-profiler.h" 56 #include "runtime-profiler.h"
56 #include "scanner-character-streams.h" 57 #include "scanner-character-streams.h"
57 #include "snapshot.h" 58 #include "snapshot.h"
58 #include "unicode-inl.h" 59 #include "unicode-inl.h"
59 #include "v8threads.h" 60 #include "v8threads.h"
60 #include "version.h" 61 #include "version.h"
61 #include "vm-state-inl.h" 62 #include "vm-state-inl.h"
62 63
63 64
64 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr)) 65 #define LOG_API(isolate, expr) LOG(isolate, ApiEntryCall(expr))
(...skipping 2682 matching lines...) Expand 10 before | Expand all | Expand 10 after
2747 2748
2748 void v8::Array::CheckCast(Value* that) { 2749 void v8::Array::CheckCast(Value* that) {
2749 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return; 2750 if (IsDeadCheck(i::Isolate::Current(), "v8::Array::Cast()")) return;
2750 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2751 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2751 ApiCheck(obj->IsJSArray(), 2752 ApiCheck(obj->IsJSArray(),
2752 "v8::Array::Cast()", 2753 "v8::Array::Cast()",
2753 "Could not convert to array"); 2754 "Could not convert to array");
2754 } 2755 }
2755 2756
2756 2757
2758 void v8::ArrayBuffer::CheckCast(Value* that) {
2759 if (IsDeadCheck(i::Isolate::Current(), "v8::ArrayBuffer::Cast()")) return;
2760 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2761 ApiCheck(obj->IsJSArrayBuffer(),
2762 "v8::ArrayBuffer::Cast()",
2763 "Could not convert to ArrayBuffer");
2764 }
2765
2766
2757 void v8::Date::CheckCast(v8::Value* that) { 2767 void v8::Date::CheckCast(v8::Value* that) {
2758 i::Isolate* isolate = i::Isolate::Current(); 2768 i::Isolate* isolate = i::Isolate::Current();
2759 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return; 2769 if (IsDeadCheck(isolate, "v8::Date::Cast()")) return;
2760 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2770 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2761 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()), 2771 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Date_string()),
2762 "v8::Date::Cast()", 2772 "v8::Date::Cast()",
2763 "Could not convert to date"); 2773 "Could not convert to date");
2764 } 2774 }
2765 2775
2766 2776
(...skipping 3018 matching lines...) Expand 10 before | Expand all | Expand 10 after
5785 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon)); 5795 i::Handle<i::JSObject> paragon_handle(i::JSObject::cast(paragon));
5786 EXCEPTION_PREAMBLE(isolate); 5796 EXCEPTION_PREAMBLE(isolate);
5787 ENTER_V8(isolate); 5797 ENTER_V8(isolate);
5788 i::Handle<i::JSObject> result = i::Copy(paragon_handle); 5798 i::Handle<i::JSObject> result = i::Copy(paragon_handle);
5789 has_pending_exception = result.is_null(); 5799 has_pending_exception = result.is_null();
5790 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>()); 5800 EXCEPTION_BAILOUT_CHECK(isolate, Local<Object>());
5791 return Utils::ToLocal(result); 5801 return Utils::ToLocal(result);
5792 } 5802 }
5793 5803
5794 5804
5805 size_t v8::ArrayBuffer::ByteLength() const {
5806 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5807 if (IsDeadCheck(isolate, "v8::ArrayBuffer::ByteLength()")) return 0;
5808 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
5809 return static_cast<size_t>(obj->byte_length()->Number());
5810 }
5811
5812
5813 void* v8::ArrayBuffer::Data() const {
5814 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
5815 if (IsDeadCheck(isolate, "v8::ArrayBuffer::Data()")) return 0;
5816 i::Handle<i::JSArrayBuffer> obj = Utils::OpenHandle(this);
5817 return obj->backing_store();
5818 }
5819
5820
5821 Local<ArrayBuffer> v8::ArrayBuffer::New(size_t byte_length) {
5822 i::Isolate* isolate = i::Isolate::Current();
5823 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(size_t)");
5824 LOG_API(isolate, "v8::ArrayBuffer::New(size_t)");
5825 ENTER_V8(isolate);
5826 i::Handle<i::JSArrayBuffer> obj =
5827 isolate->factory()->NewJSArrayBuffer();
5828 i::Runtime::SetupArrayBufferAllocatingData(isolate, obj, byte_length);
5829 return Utils::ToLocal(obj);
5830 }
5831
5832
5833 Local<ArrayBuffer> v8::ArrayBuffer::New(void* data, size_t byte_length) {
5834 i::Isolate* isolate = i::Isolate::Current();
5835 EnsureInitializedForIsolate(isolate, "v8::ArrayBuffer::New(void*, size_t)");
5836 LOG_API(isolate, "v8::ArrayBuffer::New(void*, size_t)");
5837 ENTER_V8(isolate);
5838 i::Handle<i::JSArrayBuffer> obj =
5839 isolate->factory()->NewJSArrayBuffer();
5840 i::Runtime::SetupArrayBuffer(isolate, obj, data, byte_length);
5841 return Utils::ToLocal(obj);
5842 }
5843
5844
5795 Local<Symbol> v8::Symbol::New(Isolate* isolate) { 5845 Local<Symbol> v8::Symbol::New(Isolate* isolate) {
5796 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5846 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5797 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()"); 5847 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
5798 LOG_API(i_isolate, "Symbol::New()"); 5848 LOG_API(i_isolate, "Symbol::New()");
5799 ENTER_V8(i_isolate); 5849 ENTER_V8(i_isolate);
5800 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol(); 5850 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
5801 return Utils::ToLocal(result); 5851 return Utils::ToLocal(result);
5802 } 5852 }
5803 5853
5804 5854
(...skipping 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after
7434 7484
7435 v->VisitPointers(blocks_.first(), first_block_limit_); 7485 v->VisitPointers(blocks_.first(), first_block_limit_);
7436 7486
7437 for (int i = 1; i < blocks_.length(); i++) { 7487 for (int i = 1; i < blocks_.length(); i++) {
7438 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7488 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7439 } 7489 }
7440 } 7490 }
7441 7491
7442 7492
7443 } } // namespace v8::internal 7493 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698