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 6815010: Merge r7516, r7541 into 3.1 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/3.1/
Patch Set: Created 9 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 | « src/regexp-macro-assembler-irregexp-inl.h ('k') | src/version.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 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 4314 matching lines...) Expand 10 before | Expand all | Expand 10 after
4325 static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) { 4325 static MaybeObject* Runtime_GetArgumentsProperty(Arguments args) {
4326 NoHandleAllocation ha; 4326 NoHandleAllocation ha;
4327 ASSERT(args.length() == 1); 4327 ASSERT(args.length() == 1);
4328 4328
4329 // Compute the frame holding the arguments. 4329 // Compute the frame holding the arguments.
4330 JavaScriptFrameIterator it; 4330 JavaScriptFrameIterator it;
4331 it.AdvanceToArgumentsFrame(); 4331 it.AdvanceToArgumentsFrame();
4332 JavaScriptFrame* frame = it.frame(); 4332 JavaScriptFrame* frame = it.frame();
4333 4333
4334 // Get the actual number of provided arguments. 4334 // Get the actual number of provided arguments.
4335 const uint32_t n = frame->GetProvidedParametersCount(); 4335 const uint32_t n = frame->ComputeParametersCount();
4336 4336
4337 // Try to convert the key to an index. If successful and within 4337 // Try to convert the key to an index. If successful and within
4338 // index return the the argument from the frame. 4338 // index return the the argument from the frame.
4339 uint32_t index; 4339 uint32_t index;
4340 if (args[0]->ToArrayIndex(&index) && index < n) { 4340 if (args[0]->ToArrayIndex(&index) && index < n) {
4341 return frame->GetParameter(index); 4341 return frame->GetParameter(index);
4342 } 4342 }
4343 4343
4344 // Convert the key to a string. 4344 // Convert the key to a string.
4345 HandleScope scope; 4345 HandleScope scope;
(...skipping 2534 matching lines...) Expand 10 before | Expand all | Expand 10 after
6880 bound_args = FixedArray::cast(params->elements()); 6880 bound_args = FixedArray::cast(params->elements());
6881 bound_argc = Smi::cast(params->length())->value(); 6881 bound_argc = Smi::cast(params->length())->value();
6882 } 6882 }
6883 6883
6884 // Find frame containing arguments passed to the caller. 6884 // Find frame containing arguments passed to the caller.
6885 JavaScriptFrameIterator it; 6885 JavaScriptFrameIterator it;
6886 JavaScriptFrame* frame = it.frame(); 6886 JavaScriptFrame* frame = it.frame();
6887 ASSERT(!frame->is_optimized()); 6887 ASSERT(!frame->is_optimized());
6888 it.AdvanceToArgumentsFrame(); 6888 it.AdvanceToArgumentsFrame();
6889 frame = it.frame(); 6889 frame = it.frame();
6890 int argc = frame->GetProvidedParametersCount(); 6890 int argc = frame->ComputeParametersCount();
6891 6891
6892 // Prepend bound arguments to caller's arguments. 6892 // Prepend bound arguments to caller's arguments.
6893 int total_argc = bound_argc + argc; 6893 int total_argc = bound_argc + argc;
6894 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); 6894 SmartPointer<Object**> param_data(NewArray<Object**>(total_argc));
6895 for (int i = 0; i < bound_argc; i++) { 6895 for (int i = 0; i < bound_argc; i++) {
6896 Handle<Object> val = Handle<Object>(bound_args->get(i)); 6896 Handle<Object> val = Handle<Object>(bound_args->get(i));
6897 param_data[i] = val.location(); 6897 param_data[i] = val.location();
6898 } 6898 }
6899 for (int i = 0; i < argc; i++) { 6899 for (int i = 0; i < argc; i++) {
6900 Handle<Object> val = Handle<Object>(frame->GetParameter(i)); 6900 Handle<Object> val = Handle<Object>(frame->GetParameter(i));
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
7085 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) { 7085 static MaybeObject* Runtime_NotifyDeoptimized(Arguments args) {
7086 HandleScope scope; 7086 HandleScope scope;
7087 ASSERT(args.length() == 1); 7087 ASSERT(args.length() == 1);
7088 RUNTIME_ASSERT(args[0]->IsSmi()); 7088 RUNTIME_ASSERT(args[0]->IsSmi());
7089 Deoptimizer::BailoutType type = 7089 Deoptimizer::BailoutType type =
7090 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value()); 7090 static_cast<Deoptimizer::BailoutType>(Smi::cast(args[0])->value());
7091 Deoptimizer* deoptimizer = Deoptimizer::Grab(); 7091 Deoptimizer* deoptimizer = Deoptimizer::Grab();
7092 ASSERT(Heap::IsAllocationAllowed()); 7092 ASSERT(Heap::IsAllocationAllowed());
7093 int frames = deoptimizer->output_count(); 7093 int frames = deoptimizer->output_count();
7094 7094
7095 deoptimizer->MaterializeHeapNumbers();
7096 delete deoptimizer;
7097
7095 JavaScriptFrameIterator it; 7098 JavaScriptFrameIterator it;
7096 JavaScriptFrame* frame = NULL; 7099 JavaScriptFrame* frame = NULL;
7097 for (int i = 0; i < frames; i++) { 7100 for (int i = 0; i < frames - 1; i++) it.Advance();
7098 if (i != 0) it.Advance(); 7101 frame = it.frame();
7099 frame = it.frame();
7100 deoptimizer->InsertHeapNumberValues(frames - i - 1, frame);
7101 }
7102 delete deoptimizer;
7103 7102
7104 RUNTIME_ASSERT(frame->function()->IsJSFunction()); 7103 RUNTIME_ASSERT(frame->function()->IsJSFunction());
7105 Handle<JSFunction> function(JSFunction::cast(frame->function())); 7104 Handle<JSFunction> function(JSFunction::cast(frame->function()));
7106 Handle<Object> arguments; 7105 Handle<Object> arguments;
7107 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) { 7106 for (int i = frame->ComputeExpressionsCount() - 1; i >= 0; --i) {
7108 if (frame->GetExpression(i) == Heap::arguments_marker()) { 7107 if (frame->GetExpression(i) == Heap::arguments_marker()) {
7109 if (arguments.is_null()) { 7108 if (arguments.is_null()) {
7110 // FunctionGetArguments can't throw an exception, so cast away the 7109 // FunctionGetArguments can't throw an exception, so cast away the
7111 // doubt with an assert. 7110 // doubt with an assert.
7112 arguments = Handle<Object>( 7111 arguments = Handle<Object>(
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
7713 if (fun->IsJSFunction()) { 7712 if (fun->IsJSFunction()) {
7714 PrintObject(JSFunction::cast(fun)->shared()->name()); 7713 PrintObject(JSFunction::cast(fun)->shared()->name());
7715 } else { 7714 } else {
7716 PrintObject(fun); 7715 PrintObject(fun);
7717 } 7716 }
7718 // function arguments 7717 // function arguments
7719 // (we are intentionally only printing the actually 7718 // (we are intentionally only printing the actually
7720 // supplied parameters, not all parameters required) 7719 // supplied parameters, not all parameters required)
7721 PrintF("(this="); 7720 PrintF("(this=");
7722 PrintObject(frame->receiver()); 7721 PrintObject(frame->receiver());
7723 const int length = frame->GetProvidedParametersCount(); 7722 const int length = frame->ComputeParametersCount();
7724 for (int i = 0; i < length; i++) { 7723 for (int i = 0; i < length; i++) {
7725 PrintF(", "); 7724 PrintF(", ");
7726 PrintObject(frame->GetParameter(i)); 7725 PrintObject(frame->GetParameter(i));
7727 } 7726 }
7728 PrintF(") {\n"); 7727 PrintF(") {\n");
7729 7728
7730 } else { 7729 } else {
7731 // function result 7730 // function result
7732 PrintF("} -> "); 7731 PrintF("} -> ");
7733 PrintObject(result); 7732 PrintObject(result);
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
9216 9215
9217 // Now advance to the arguments adapter frame (if any). It contains all 9216 // Now advance to the arguments adapter frame (if any). It contains all
9218 // the provided parameters whereas the function frame always have the number 9217 // the provided parameters whereas the function frame always have the number
9219 // of arguments matching the functions parameters. The rest of the 9218 // of arguments matching the functions parameters. The rest of the
9220 // information (except for what is collected above) is the same. 9219 // information (except for what is collected above) is the same.
9221 it.AdvanceToArgumentsFrame(); 9220 it.AdvanceToArgumentsFrame();
9222 9221
9223 // Find the number of arguments to fill. At least fill the number of 9222 // Find the number of arguments to fill. At least fill the number of
9224 // parameters for the function and fill more if more parameters are provided. 9223 // parameters for the function and fill more if more parameters are provided.
9225 int argument_count = info.number_of_parameters(); 9224 int argument_count = info.number_of_parameters();
9226 if (argument_count < it.frame()->GetProvidedParametersCount()) { 9225 if (argument_count < it.frame()->ComputeParametersCount()) {
9227 argument_count = it.frame()->GetProvidedParametersCount(); 9226 argument_count = it.frame()->ComputeParametersCount();
9228 } 9227 }
9229 9228
9230 // Calculate the size of the result. 9229 // Calculate the size of the result.
9231 int details_size = kFrameDetailsFirstDynamicIndex + 9230 int details_size = kFrameDetailsFirstDynamicIndex +
9232 2 * (argument_count + info.NumberOfLocals()) + 9231 2 * (argument_count + info.NumberOfLocals()) +
9233 (at_return ? 1 : 0); 9232 (at_return ? 1 : 0);
9234 Handle<FixedArray> details = Factory::NewFixedArray(details_size); 9233 Handle<FixedArray> details = Factory::NewFixedArray(details_size);
9235 9234
9236 // Add the frame id. 9235 // Add the frame id.
9237 details->set(kFrameDetailsFrameIdIndex, *frame_id); 9236 details->set(kFrameDetailsFrameIdIndex, *frame_id);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
9274 } else { 9273 } else {
9275 details->set(details_index++, Heap::undefined_value()); 9274 details->set(details_index++, Heap::undefined_value());
9276 } 9275 }
9277 9276
9278 // Parameter value. If we are inspecting an optimized frame, use 9277 // Parameter value. If we are inspecting an optimized frame, use
9279 // undefined as the value. 9278 // undefined as the value.
9280 // 9279 //
9281 // TODO(3141533): We should be able to get the actual parameter 9280 // TODO(3141533): We should be able to get the actual parameter
9282 // value for optimized frames. 9281 // value for optimized frames.
9283 if (!is_optimized_frame && 9282 if (!is_optimized_frame &&
9284 (i < it.frame()->GetProvidedParametersCount())) { 9283 (i < it.frame()->ComputeParametersCount())) {
9285 details->set(details_index++, it.frame()->GetParameter(i)); 9284 details->set(details_index++, it.frame()->GetParameter(i));
9286 } else { 9285 } else {
9287 details->set(details_index++, Heap::undefined_value()); 9286 details->set(details_index++, Heap::undefined_value());
9288 } 9287 }
9289 } 9288 }
9290 9289
9291 // Add locals name and value from the temporary copy from the function frame. 9290 // Add locals name and value from the temporary copy from the function frame.
9292 for (int i = 0; i < info.NumberOfLocals() * 2; i++) { 9291 for (int i = 0; i < info.NumberOfLocals() * 2; i++) {
9293 details->set(details_index++, locals->get(i)); 9292 details->set(details_index++, locals->get(i));
9294 } 9293 }
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
10154 } 10153 }
10155 } 10154 }
10156 10155
10157 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) { 10156 if (sinfo->number_of_context_slots() > Context::MIN_CONTEXT_SLOTS) {
10158 index = scope_info->ContextSlotIndex(Heap::arguments_symbol(), NULL); 10157 index = scope_info->ContextSlotIndex(Heap::arguments_symbol(), NULL);
10159 if (index != -1) { 10158 if (index != -1) {
10160 return Handle<Object>(function_context->get(index)); 10159 return Handle<Object>(function_context->get(index));
10161 } 10160 }
10162 } 10161 }
10163 10162
10164 const int length = frame->GetProvidedParametersCount(); 10163 const int length = frame->ComputeParametersCount();
10165 Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length); 10164 Handle<JSObject> arguments = Factory::NewArgumentsObject(function, length);
10166 Handle<FixedArray> array = Factory::NewFixedArray(length); 10165 Handle<FixedArray> array = Factory::NewFixedArray(length);
10167 10166
10168 AssertNoAllocation no_gc; 10167 AssertNoAllocation no_gc;
10169 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc); 10168 WriteBarrierMode mode = array->GetWriteBarrierMode(no_gc);
10170 for (int i = 0; i < length; i++) { 10169 for (int i = 0; i < length; i++) {
10171 array->set(i, frame->GetParameter(i), mode); 10170 array->set(i, frame->GetParameter(i), mode);
10172 } 10171 }
10173 arguments->set_elements(*array); 10172 arguments->set_elements(*array);
10174 return arguments; 10173 return arguments;
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
11583 } else { 11582 } else {
11584 // Handle last resort GC and make sure to allow future allocations 11583 // Handle last resort GC and make sure to allow future allocations
11585 // to grow the heap without causing GCs (if possible). 11584 // to grow the heap without causing GCs (if possible).
11586 Counters::gc_last_resort_from_js.Increment(); 11585 Counters::gc_last_resort_from_js.Increment();
11587 Heap::CollectAllGarbage(false); 11586 Heap::CollectAllGarbage(false);
11588 } 11587 }
11589 } 11588 }
11590 11589
11591 11590
11592 } } // namespace v8::internal 11591 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/regexp-macro-assembler-irregexp-inl.h ('k') | src/version.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698