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

Side by Side Diff: src/runtime.cc

Issue 235943015: Handlify callers of AllocateUninitializedFixedArray. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | no next file » | 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 6786 matching lines...) Expand 10 before | Expand all | Expand 10 after
6797 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); 6797 CONVERT_ARG_HANDLE_CHECKED(String, s, 0);
6798 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]); 6798 CONVERT_NUMBER_CHECKED(uint32_t, limit, Uint32, args[1]);
6799 6799
6800 s = String::Flatten(s); 6800 s = String::Flatten(s);
6801 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit)); 6801 const int length = static_cast<int>(Min<uint32_t>(s->length(), limit));
6802 6802
6803 Handle<FixedArray> elements; 6803 Handle<FixedArray> elements;
6804 int position = 0; 6804 int position = 0;
6805 if (s->IsFlat() && s->IsOneByteRepresentation()) { 6805 if (s->IsFlat() && s->IsOneByteRepresentation()) {
6806 // Try using cached chars where possible. 6806 // Try using cached chars where possible.
6807 Object* obj; 6807 elements = isolate->factory()->NewUninitializedFixedArray(length);
6808 { MaybeObject* maybe_obj = 6808
6809 isolate->heap()->AllocateUninitializedFixedArray(length);
6810 if (!maybe_obj->ToObject(&obj)) return maybe_obj;
6811 }
6812 elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);
6813 DisallowHeapAllocation no_gc; 6809 DisallowHeapAllocation no_gc;
6814 String::FlatContent content = s->GetFlatContent(); 6810 String::FlatContent content = s->GetFlatContent();
6815 if (content.IsAscii()) { 6811 if (content.IsAscii()) {
6816 Vector<const uint8_t> chars = content.ToOneByteVector(); 6812 Vector<const uint8_t> chars = content.ToOneByteVector();
6817 // Note, this will initialize all elements (not only the prefix) 6813 // Note, this will initialize all elements (not only the prefix)
6818 // to prevent GC from seeing partially initialized array. 6814 // to prevent GC from seeing partially initialized array.
6819 position = CopyCachedAsciiCharsToArray(isolate->heap(), 6815 position = CopyCachedAsciiCharsToArray(isolate->heap(),
6820 chars.start(), 6816 chars.start(),
6821 *elements, 6817 *elements,
6822 length); 6818 length);
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
7978 for (int i = 0; i < argument_count; ++i) { 7974 for (int i = 0; i < argument_count; ++i) {
7979 elements->set(i, *(parameters - i - 1)); 7975 elements->set(i, *(parameters - i - 1));
7980 } 7976 }
7981 } 7977 }
7982 } 7978 }
7983 return *result; 7979 return *result;
7984 } 7980 }
7985 7981
7986 7982
7987 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewStrictArgumentsFast) { 7983 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewStrictArgumentsFast) {
7988 SealHandleScope shs(isolate); 7984 HandleScope scope(isolate);
7989 ASSERT(args.length() == 3); 7985 ASSERT(args.length() == 3);
7986 CONVERT_ARG_HANDLE_CHECKED(JSFunction, callee, 0)
7987 Object** parameters = reinterpret_cast<Object**>(args[1]);
7988 CONVERT_SMI_ARG_CHECKED(length, 2);
7990 7989
7991 JSFunction* callee = JSFunction::cast(args[0]); 7990 Handle<JSObject> result =
7992 Object** parameters = reinterpret_cast<Object**>(args[1]); 7991 isolate->factory()->NewArgumentsObject(callee, length);
7993 const int length = args.smi_at(2);
7994 7992
7995 Object* result;
7996 { MaybeObject* maybe_result =
7997 isolate->heap()->AllocateArgumentsObject(callee, length);
7998 if (!maybe_result->ToObject(&result)) return maybe_result;
7999 }
8000 // Allocate the elements if needed.
8001 if (length > 0) { 7993 if (length > 0) {
8002 // Allocate the fixed array. 7994 Handle<FixedArray> array =
8003 FixedArray* array; 7995 isolate->factory()->NewUninitializedFixedArray(length);
8004 { MaybeObject* maybe_obj =
8005 isolate->heap()->AllocateUninitializedFixedArray(length);
8006 if (!maybe_obj->To(&array)) return maybe_obj;
8007 }
8008
8009 DisallowHeapAllocation no_gc; 7996 DisallowHeapAllocation no_gc;
8010 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); 7997 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
8011 for (int i = 0; i < length; i++) { 7998 for (int i = 0; i < length; i++) {
8012 array->set(i, *--parameters, mode); 7999 array->set(i, *--parameters, mode);
8013 } 8000 }
8014 JSObject::cast(result)->set_elements(array); 8001 result->set_elements(*array);
8015 } 8002 }
8016 return result; 8003 return *result;
8017 } 8004 }
8018 8005
8019 8006
8020 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosureFromStubFailure) { 8007 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewClosureFromStubFailure) {
8021 HandleScope scope(isolate); 8008 HandleScope scope(isolate);
8022 ASSERT(args.length() == 1); 8009 ASSERT(args.length() == 1);
8023 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0); 8010 CONVERT_ARG_HANDLE_CHECKED(SharedFunctionInfo, shared, 0);
8024 Handle<Context> context(isolate->context()); 8011 Handle<Context> context(isolate->context());
8025 PretenureFlag pretenure_flag = NOT_TENURED; 8012 PretenureFlag pretenure_flag = NOT_TENURED;
8026 Handle<JSFunction> result = 8013 Handle<JSFunction> result =
(...skipping 7052 matching lines...) Expand 10 before | Expand all | Expand 10 after
15079 } 15066 }
15080 } 15067 }
15081 15068
15082 15069
15083 void Runtime::OutOfMemory() { 15070 void Runtime::OutOfMemory() {
15084 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15071 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15085 UNREACHABLE(); 15072 UNREACHABLE();
15086 } 15073 }
15087 15074
15088 } } // namespace v8::internal 15075 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698