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

Side by Side Diff: src/runtime.cc

Issue 209083005: Allow to neuter array buffer twice in tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | « no previous file | test/mjsunit/neuter-twice.js » ('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 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 CONVERT_ARG_CHECKED(Object, object, 0); 904 CONVERT_ARG_CHECKED(Object, object, 0);
905 return object->IsJSArrayBufferView() 905 return object->IsJSArrayBufferView()
906 ? isolate->heap()->true_value() 906 ? isolate->heap()->true_value()
907 : isolate->heap()->false_value(); 907 : isolate->heap()->false_value();
908 } 908 }
909 909
910 910
911 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) { 911 RUNTIME_FUNCTION(MaybeObject*, Runtime_ArrayBufferNeuter) {
912 HandleScope scope(isolate); 912 HandleScope scope(isolate);
913 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); 913 CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0);
914 if (array_buffer->backing_store() == NULL) {
915 CHECK(Smi::FromInt(0) == array_buffer->byte_length());
916 return isolate->heap()->undefined_value();
917 }
Jarin 2014/03/25 10:59:42 How about keeping just one return statement? That
Dmitry Lomov (no reviews) 2014/03/25 11:04:25 I think that complicates code for the edge case.
Sven Panne 2014/03/25 11:30:35 Actually I like the initial version, too, a "comb-
914 ASSERT(!array_buffer->is_external()); 918 ASSERT(!array_buffer->is_external());
915 void* backing_store = array_buffer->backing_store(); 919 void* backing_store = array_buffer->backing_store();
916 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); 920 size_t byte_length = NumberToSize(isolate, array_buffer->byte_length());
917 array_buffer->set_is_external(true); 921 array_buffer->set_is_external(true);
918 Runtime::NeuterArrayBuffer(array_buffer); 922 Runtime::NeuterArrayBuffer(array_buffer);
919 V8::ArrayBufferAllocator()->Free(backing_store, byte_length); 923 V8::ArrayBufferAllocator()->Free(backing_store, byte_length);
920 return isolate->heap()->undefined_value(); 924 return isolate->heap()->undefined_value();
921 } 925 }
922 926
923 927
(...skipping 14184 matching lines...) Expand 10 before | Expand all | Expand 10 after
15108 // Handle last resort GC and make sure to allow future allocations 15112 // Handle last resort GC and make sure to allow future allocations
15109 // to grow the heap without causing GCs (if possible). 15113 // to grow the heap without causing GCs (if possible).
15110 isolate->counters()->gc_last_resort_from_js()->Increment(); 15114 isolate->counters()->gc_last_resort_from_js()->Increment();
15111 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, 15115 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags,
15112 "Runtime::PerformGC"); 15116 "Runtime::PerformGC");
15113 } 15117 }
15114 } 15118 }
15115 15119
15116 15120
15117 } } // namespace v8::internal 15121 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/neuter-twice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698