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

Side by Side Diff: src/d8.cc

Issue 12790004: Made AdjustAmountOfExternalAllocatedMemory an instance method of Isolate (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Feedback Created 7 years, 9 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.cc ('k') | test/cctest/test-api.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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 if (data == NULL) { 382 if (data == NULL) {
383 return Throw("Memory allocation failed"); 383 return Throw("Memory allocation failed");
384 } 384 }
385 memset(data, 0, length); 385 memset(data, 0, length);
386 386
387 buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True()); 387 buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True());
388 Persistent<Object> persistent_array = 388 Persistent<Object> persistent_array =
389 Persistent<Object>::New(isolate, buffer); 389 Persistent<Object>::New(isolate, buffer);
390 persistent_array.MakeWeak(isolate, data, ExternalArrayWeakCallback); 390 persistent_array.MakeWeak(isolate, data, ExternalArrayWeakCallback);
391 persistent_array.MarkIndependent(isolate); 391 persistent_array.MarkIndependent(isolate);
392 V8::AdjustAmountOfExternalAllocatedMemory(length); 392 isolate->AdjustAmountOfExternalAllocatedMemory(length);
393 393
394 buffer->SetIndexedPropertiesToExternalArrayData( 394 buffer->SetIndexedPropertiesToExternalArrayData(
395 data, v8::kExternalByteArray, length); 395 data, v8::kExternalByteArray, length);
396 buffer->Set(Symbols::byteLength(isolate), 396 buffer->Set(Symbols::byteLength(isolate),
397 Int32::New(length, isolate), 397 Int32::New(length, isolate),
398 ReadOnly); 398 ReadOnly);
399 399
400 return buffer; 400 return buffer;
401 } 401 }
402 402
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 return Undefined(args.GetIsolate()); 823 return Undefined(args.GetIsolate());
824 } 824 }
825 825
826 826
827 void Shell::ExternalArrayWeakCallback(v8::Isolate* isolate, 827 void Shell::ExternalArrayWeakCallback(v8::Isolate* isolate,
828 Persistent<Value> object, 828 Persistent<Value> object,
829 void* data) { 829 void* data) {
830 HandleScope scope; 830 HandleScope scope;
831 int32_t length = 831 int32_t length =
832 object->ToObject()->Get(Symbols::byteLength(isolate))->Uint32Value(); 832 object->ToObject()->Get(Symbols::byteLength(isolate))->Uint32Value();
833 V8::AdjustAmountOfExternalAllocatedMemory(-length); 833 isolate->AdjustAmountOfExternalAllocatedMemory(-length);
834 delete[] static_cast<uint8_t*>(data); 834 delete[] static_cast<uint8_t*>(data);
835 object.Dispose(isolate); 835 object.Dispose(isolate);
836 } 836 }
837 837
838 838
839 Handle<Value> Shell::Int8Array(const Arguments& args) { 839 Handle<Value> Shell::Int8Array(const Arguments& args) {
840 return CreateExternalArray(args, v8::kExternalByteArray, sizeof(int8_t)); 840 return CreateExternalArray(args, v8::kExternalByteArray, sizeof(int8_t));
841 } 841 }
842 842
843 843
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 if (data == NULL) { 1439 if (data == NULL) {
1440 return Throw("Error reading file"); 1440 return Throw("Error reading file");
1441 } 1441 }
1442 Isolate* isolate = args.GetIsolate(); 1442 Isolate* isolate = args.GetIsolate();
1443 Handle<Object> buffer = Object::New(); 1443 Handle<Object> buffer = Object::New();
1444 buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True()); 1444 buffer->SetHiddenValue(Symbols::ArrayBufferMarkerPropName(isolate), True());
1445 Persistent<Object> persistent_buffer = 1445 Persistent<Object> persistent_buffer =
1446 Persistent<Object>::New(isolate, buffer); 1446 Persistent<Object>::New(isolate, buffer);
1447 persistent_buffer.MakeWeak(isolate, data, ExternalArrayWeakCallback); 1447 persistent_buffer.MakeWeak(isolate, data, ExternalArrayWeakCallback);
1448 persistent_buffer.MarkIndependent(isolate); 1448 persistent_buffer.MarkIndependent(isolate);
1449 V8::AdjustAmountOfExternalAllocatedMemory(length); 1449 isolate->AdjustAmountOfExternalAllocatedMemory(length);
1450 1450
1451 buffer->SetIndexedPropertiesToExternalArrayData( 1451 buffer->SetIndexedPropertiesToExternalArrayData(
1452 data, kExternalUnsignedByteArray, length); 1452 data, kExternalUnsignedByteArray, length);
1453 buffer->Set(Symbols::byteLength(isolate), 1453 buffer->Set(Symbols::byteLength(isolate),
1454 Int32::New(static_cast<int32_t>(length), isolate), ReadOnly); 1454 Int32::New(static_cast<int32_t>(length), isolate), ReadOnly);
1455 return buffer; 1455 return buffer;
1456 } 1456 }
1457 1457
1458 1458
1459 #ifndef V8_SHARED 1459 #ifndef V8_SHARED
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1962 } 1962 }
1963 1963
1964 } // namespace v8 1964 } // namespace v8
1965 1965
1966 1966
1967 #ifndef GOOGLE3 1967 #ifndef GOOGLE3
1968 int main(int argc, char* argv[]) { 1968 int main(int argc, char* argv[]) {
1969 return v8::Shell::Main(argc, argv); 1969 return v8::Shell::Main(argc, argv);
1970 } 1970 }
1971 #endif 1971 #endif
OLDNEW
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698