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

Side by Side Diff: src/runtime.cc

Issue 6635042: Remove GetProvidedParametersCount from JavaScriptFrame, it simply calls Compu... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 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/frames.cc ('k') | 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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 4326 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) { 4337 static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) {
4338 NoHandleAllocation ha; 4338 NoHandleAllocation ha;
4339 ASSERT(args.length() == 1); 4339 ASSERT(args.length() == 1);
4340 4340
4341 // Compute the frame holding the arguments. 4341 // Compute the frame holding the arguments.
4342 JavaScriptFrameIterator it; 4342 JavaScriptFrameIterator it;
4343 it.AdvanceToArgumentsFrame(); 4343 it.AdvanceToArgumentsFrame();
4344 JavaScriptFrame* frame = it.frame(); 4344 JavaScriptFrame* frame = it.frame();
4345 4345
4346 // Get the actual number of provided arguments. 4346 // Get the actual number of provided arguments.
4347 const uint32_t n = frame->GetProvidedParametersCount(); 4347 const uint32_t n = frame->ComputeParametersCount();
4348 4348
4349 // Try to convert the key to an index. If successful and within 4349 // Try to convert the key to an index. If successful and within
4350 // index return the the argument from the frame. 4350 // index return the the argument from the frame.
4351 uint32_t index; 4351 uint32_t index;
4352 if (args[0]->ToArrayIndex(&index) && index < n) { 4352 if (args[0]->ToArrayIndex(&index) && index < n) {
4353 return frame->GetParameter(index); 4353 return frame->GetParameter(index);
4354 } 4354 }
4355 4355
4356 // Convert the key to a string. 4356 // Convert the key to a string.
4357 HandleScope scope; 4357 HandleScope scope;
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
6892 bound_args = FixedArray::cast(params->elements()); 6892 bound_args = FixedArray::cast(params->elements());
6893 bound_argc = Smi::cast(params->length())->value(); 6893 bound_argc = Smi::cast(params->length())->value();
6894 } 6894 }
6895 6895
6896 // Find frame containing arguments passed to the caller. 6896 // Find frame containing arguments passed to the caller.
6897 JavaScriptFrameIterator it; 6897 JavaScriptFrameIterator it;
6898 JavaScriptFrame* frame = it.frame(); 6898 JavaScriptFrame* frame = it.frame();
6899 ASSERT(!frame->is_optimized()); 6899 ASSERT(!frame->is_optimized());
6900 it.AdvanceToArgumentsFrame(); 6900 it.AdvanceToArgumentsFrame();
6901 frame = it.frame(); 6901 frame = it.frame();
6902 int argc = frame->GetProvidedParametersCount(); 6902 int argc = frame->ComputeParametersCount();
6903 6903
6904 // Prepend bound arguments to caller's arguments. 6904 // Prepend bound arguments to caller's arguments.
6905 int total_argc = bound_argc + argc; 6905 int total_argc = bound_argc + argc;
6906 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); 6906 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc));
6907 for (int i = 0; i < bound_argc; i++) { 6907 for (int i = 0; i < bound_argc; i++) {
6908 Handle<Object> val = Handle<Object>(bound_args->get(i)); 6908 Handle<Object> val = Handle<Object>(bound_args->get(i));
6909 param_data[i] = val.location(); 6909 param_data[i] = val.location();
6910 } 6910 }
6911 for (int i = 0; i < argc; i++) { 6911 for (int i = 0; i < argc; i++) {
6912 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); 6912 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
7731 if (fun->IsJSFunction()) { 7731 if (fun->IsJSFunction()) {
7732 PrintObject(JSFunction::cast(fun)->shared()->name()); 7732 PrintObject(JSFunction::cast(fun)->shared()->name());
7733 } else { 7733 } else {
7734 PrintObject(fun); 7734 PrintObject(fun);
7735 } 7735 }
7736 // function arguments 7736 // function arguments
7737 // (we are intentionally only printing the actually 7737 // (we are intentionally only printing the actually
7738 // supplied parameters, not all parameters required) 7738 // supplied parameters, not all parameters required)
7739 PrintF("(this="); 7739 PrintF("(this=");
7740 PrintObject(frame->receiver()); 7740 PrintObject(frame->receiver());
7741 const int length = frame->GetProvidedParametersCount(); 7741 const int length = frame->ComputeParametersCount();
7742 for (int i = 0; i < length; i++) { 7742 for (int i = 0; i < length; i++) {
7743 PrintF(", "); 7743 PrintF(", ");
7744 PrintObject(frame->GetParameter(i)); 7744 PrintObject(frame->GetParameter(i));
7745 } 7745 }
7746 PrintF(") {\n"); 7746 PrintF(") {\n");
7747 7747
7748 } else { 7748 } else {
7749 // function result 7749 // function result
7750 PrintF("} -> "); 7750 PrintF("} -> ");
7751 PrintObject(result); 7751 PrintObject(result);
(...skipping 1492 matching lines...) Expand 10 before | Expand all | Expand 10 after
9244 9244
9245 // Now advance to the arguments adapter frame (if any). It contains all 9245 // Now advance to the arguments adapter frame (if any). It contains all
9246 // the provided parameters whereas the function frame always have the number 9246 // the provided parameters whereas the function frame always have the number
9247 // of arguments matching the functions parameters. The rest of the 9247 // of arguments matching the functions parameters. The rest of the
9248 // information (except for what is collected above) is the same. 9248 // information (except for what is collected above) is the same.
9249 it.AdvanceToArgumentsFrame(); 9249 it.AdvanceToArgumentsFrame();
9250 9250
9251 // Find the number of arguments to fill. At least fill the number of 9251 // Find the number of arguments to fill. At least fill the number of
9252 // parameters for the function and fill more if more parameters are provided. 9252 // parameters for the function and fill more if more parameters are provided.
9253 int argument_count = info.number_of_parameters(); 9253 int argument_count = info.number_of_parameters();
9254 if (argument_count < it.frame()->GetProvidedParametersCount()) { 9254 if (argument_count < it.frame()->ComputeParametersCount()) {
9255 argument_count = it.frame()->GetProvidedParametersCount(); 9255 argument_count = it.frame()->ComputeParametersCount();
9256 } 9256 }
9257 9257
9258 // Calculate the size of the result. 9258 // Calculate the size of the result.
9259 int details_size = kFrameDetailsFirstDynamicIndex + 9259 int details_size = kFrameDetailsFirstDynamicIndex +
9260 2 * (argument_count + info.NumberOfLocals()) + 9260 2 * (argument_count + info.NumberOfLocals()) +
9261 (at_return ? 1 : 0); 9261 (at_return ? 1 : 0);
9262 Handle<FixedArray> details = Factory::NewFixedArray(details_size); 9262 Handle<FixedArray> details = Factory::NewFixedArray(details_size);
9263 9263
9264 // Add the frame id. 9264 // Add the frame id.
9265 details->set(kFrameDetailsFrameIdIndex, *frame_id); 9265 details->set(kFrameDetailsFrameIdIndex, *frame_id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
9302 } else { 9302 } else {
9303 details->set(details_index++, Heap::undefined_value()); 9303 details->set(details_index++, Heap::undefined_value());
9304 } 9304 }
9305 9305
9306 // Parameter value. If we are inspecting an optimized frame, use 9306 // Parameter value. If we are inspecting an optimized frame, use
9307 // undefined as the value. 9307 // undefined as the value.
9308 // 9308 //
9309 // TODO(3141533): We should be able to get the actual parameter 9309 // TODO(3141533): We should be able to get the actual parameter
9310 // value for optimized frames. 9310 // value for optimized frames.
9311 if (!is_optimized_frame && 9311 if (!is_optimized_frame &&
9312 (i < it.frame()->GetProvidedParametersCount())) { 9312 (i < it.frame()->ComputeParametersCount())) {
9313 details->set(details_index++, it.frame()->GetParameter(i)); 9313 details->set(details_index++, it.frame()->GetParameter(i));
9314 } else { 9314 } else {
9315 details->set(details_index++, Heap::undefined_value()); 9315 details->set(details_index++, Heap::undefined_value());
9316 } 9316 }
9317 } 9317 }
9318 9318
9319 // Add locals name and value from the temporary copy from the function frame. 9319 // Add locals name and value from the temporary copy from the function frame.
9320 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { 9320 for (int i = 0; i < info.NumberOfLocals() * 2; i++) {
9321 details->set(details_index++, locals->get(i)); 9321 details->set(details_index++, locals->get(i));
9322 } 9322 }
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
10182 } 10182 }
10183 } 10183 }
10184 10184
10185 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { 10185 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) {
10186 index = scope_info->ContextSlotIndex(Heap::arguments_symbol(), NULL); 10186 index = scope_info->ContextSlotIndex(Heap::arguments_symbol(), NULL);
10187 if (index != -1) { 10187 if (index != -1) {
10188 return Handle<Object>(function_context->get(index)); 10188 return Handle<Object>(function_context->get(index));
10189 } 10189 }
10190 } 10190 }
10191 10191
10192 const int length = frame->GetProvidedParametersCount(); 10192 const int length = frame->ComputeParametersCount();
10193 Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length); 10193 Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length);
10194 Handle<FixedArray> array = Factory::NewFixedArray(length); 10194 Handle<FixedArray> array = Factory::NewFixedArray(length);
10195 10195
10196 AssertNoAllocation no_gc; 10196 AssertNoAllocation no_gc;
10197 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); 10197 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
10198 for (int i = 0; i < length; i++) { 10198 for (int i = 0; i < length; i++) {
10199 array->set(i, frame->GetParameter(i), mode); 10199 array->set(i, frame->GetParameter(i), mode);
10200 } 10200 }
10201 arguments->set_elements(*array); 10201 arguments->set_elements(*array);
10202 return arguments; 10202 return arguments;
(...skipping 1421 matching lines...) Expand 10 before | Expand all | Expand 10 after
11624 } else { 11624 } else {
11625 // Handle last resort GC and make sure to allow future allocations 11625 // Handle last resort GC and make sure to allow future allocations
11626 // to grow the heap without causing GCs (if possible). 11626 // to grow the heap without causing GCs (if possible).
11627 Counters::gc_last_resort_from_js.Increment(); 11627 Counters::gc_last_resort_from_js.Increment();
11628 Heap::CollectAllGarbage(false); 11628 Heap::CollectAllGarbage(false);
11629 } 11629 }
11630 } 11630 }
11631 11631
11632 11632
11633 } } // namespace v8::internal 11633 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/frames.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698