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

Side by Side Diff: src/runtime.cc

Issue 8659: Fix lint issues. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 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 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 4067 matching lines...) Expand 10 before | Expand all | Expand 10 after
4078 } 4078 }
4079 4079
4080 4080
4081 /** 4081 /**
4082 * A helper function that visits elements of an Array object, and elements 4082 * A helper function that visits elements of an Array object, and elements
4083 * on its prototypes. 4083 * on its prototypes.
4084 * 4084 *
4085 * Elements on prototypes are visited first, and only elements whose indices 4085 * Elements on prototypes are visited first, and only elements whose indices
4086 * less than Array length are visited. 4086 * less than Array length are visited.
4087 * 4087 *
4088 * If a ArrayConcatVisitor object is given, the visitor is called with 4088 * If a ArrayConcatVisitor object is given, the visitor is called with
4089 * parameters, element's index + visitor_index_offset and the element. 4089 * parameters, element's index + visitor_index_offset and the element.
4090 */ 4090 */
4091 static uint32_t IterateArrayAndPrototypeElements(Handle<JSArray> array, 4091 static uint32_t IterateArrayAndPrototypeElements(Handle<JSArray> array,
4092 ArrayConcatVisitor* visitor) { 4092 ArrayConcatVisitor* visitor) {
4093 uint32_t range = static_cast<uint32_t>(array->length()->Number()); 4093 uint32_t range = static_cast<uint32_t>(array->length()->Number());
4094 Handle<Object> obj = array; 4094 Handle<Object> obj = array;
4095 4095
4096 static const int kEstimatedPrototypes = 3; 4096 static const int kEstimatedPrototypes = 3;
4097 List< Handle<JSObject> > objects(kEstimatedPrototypes); 4097 List< Handle<JSObject> > objects(kEstimatedPrototypes);
4098 4098
4099 // Visit prototype first. If an element on the prototype is shadowed by 4099 // Visit prototype first. If an element on the prototype is shadowed by
4100 // the inheritor using the same index, the ArrayConcatVisitor visits 4100 // the inheritor using the same index, the ArrayConcatVisitor visits
4101 // the prototype element before the shadowing element. 4101 // the prototype element before the shadowing element.
4102 // The visitor can simply overwrite the old value by new value using 4102 // The visitor can simply overwrite the old value by new value using
4103 // the same index. This follows Array::concat semantics. 4103 // the same index. This follows Array::concat semantics.
4104 while(!obj->IsNull()) { 4104 while (!obj->IsNull()) {
4105 objects.Add(obj); 4105 objects.Add(obj);
4106 obj = Handle<Object>(obj->GetPrototype()); 4106 obj = Handle<Object>(obj->GetPrototype());
4107 } 4107 }
4108 4108
4109 uint32_t nof_elements = 0; 4109 uint32_t nof_elements = 0;
4110 for (int i = objects.length() - 1; i >= 0; i--) { 4110 for (int i = objects.length() - 1; i >= 0; i--) {
4111 Handle<JSObject> obj = objects[i]; 4111 Handle<JSObject> obj = objects[i];
4112 nof_elements += 4112 nof_elements +=
4113 IterateElements(Handle<JSObject>::cast(obj), range, visitor); 4113 IterateElements(Handle<JSObject>::cast(obj), range, visitor);
4114 } 4114 }
4115 4115
4116 return nof_elements; 4116 return nof_elements;
4117 } 4117 }
4118 4118
4119 4119
4120 /** 4120 /**
4121 * A helper function of Runtime_ArrayConcat. 4121 * A helper function of Runtime_ArrayConcat.
4122 * 4122 *
4123 * The first argument is an Array of Arrays and objects. It is the same as 4123 * The first argument is an Array of Arrays and objects. It is the same as
4124 * the arguments array of Array::concat JS function. 4124 * the arguments array of Array::concat JS function.
4125 * 4125 *
4126 * If an argument is an Array object, the function visits array elements. 4126 * If an argument is an Array object, the function visits array elements.
(...skipping 17 matching lines...) Expand all
4144 // the array length number of elements. 4144 // the array length number of elements.
4145 visited_elements += (nof_elements > len) ? len : nof_elements; 4145 visited_elements += (nof_elements > len) ? len : nof_elements;
4146 if (visitor) visitor->increase_index_offset(len); 4146 if (visitor) visitor->increase_index_offset(len);
4147 4147
4148 } else { 4148 } else {
4149 if (visitor) { 4149 if (visitor) {
4150 visitor->visit(0, obj); 4150 visitor->visit(0, obj);
4151 visitor->increase_index_offset(1); 4151 visitor->increase_index_offset(1);
4152 } 4152 }
4153 visited_elements++; 4153 visited_elements++;
4154 } 4154 }
4155 } 4155 }
4156 return visited_elements; 4156 return visited_elements;
4157 } 4157 }
4158 4158
4159 4159
4160 /** 4160 /**
4161 * Array::concat implementation. 4161 * Array::concat implementation.
4162 * See ECMAScript 262, 15.4.4.4. 4162 * See ECMAScript 262, 15.4.4.4.
4163 */ 4163 */
4164 static Object* Runtime_ArrayConcat(Arguments args) { 4164 static Object* Runtime_ArrayConcat(Arguments args) {
(...skipping 1589 matching lines...) Expand 10 before | Expand all | Expand 10 after
5754 5754
5755 void Runtime::PerformGC(Object* result) { 5755 void Runtime::PerformGC(Object* result) {
5756 Failure* failure = Failure::cast(result); 5756 Failure* failure = Failure::cast(result);
5757 // Try to do a garbage collection; ignore it if it fails. The C 5757 // Try to do a garbage collection; ignore it if it fails. The C
5758 // entry stub will throw an out-of-memory exception in that case. 5758 // entry stub will throw an out-of-memory exception in that case.
5759 Heap::CollectGarbage(failure->requested(), failure->allocation_space()); 5759 Heap::CollectGarbage(failure->requested(), failure->allocation_space());
5760 } 5760 }
5761 5761
5762 5762
5763 } } // namespace v8::internal 5763 } } // 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