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

Side by Side Diff: src/runtime.cc

Issue 253263003: ScopeInfo::ContextSlotIndex() handlified. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 7 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/objects.h ('k') | src/scopeinfo.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <limits> 6 #include <limits>
7 7
8 #include "v8.h" 8 #include "v8.h"
9 9
10 #include "accessors.h" 10 #include "accessors.h"
(...skipping 11233 matching lines...) Expand 10 before | Expand all | Expand 10 after
11244 Handle<Context> context( 11244 Handle<Context> context(
11245 Context::cast(it.frame()->context())->declaration_context()); 11245 Context::cast(it.frame()->context())->declaration_context());
11246 for (; i < scope_info->LocalCount(); ++i) { 11246 for (; i < scope_info->LocalCount(); ++i) {
11247 if (scope_info->LocalIsSynthetic(i)) 11247 if (scope_info->LocalIsSynthetic(i))
11248 continue; 11248 continue;
11249 Handle<String> name(scope_info->LocalName(i)); 11249 Handle<String> name(scope_info->LocalName(i));
11250 VariableMode mode; 11250 VariableMode mode;
11251 InitializationFlag init_flag; 11251 InitializationFlag init_flag;
11252 locals->set(local * 2, *name); 11252 locals->set(local * 2, *name);
11253 int context_slot_index = 11253 int context_slot_index =
11254 scope_info->ContextSlotIndex(*name, &mode, &init_flag); 11254 ScopeInfo::ContextSlotIndex(scope_info, name, &mode, &init_flag);
11255 Object* value = context->get(context_slot_index); 11255 Object* value = context->get(context_slot_index);
11256 locals->set(local * 2 + 1, value); 11256 locals->set(local * 2 + 1, value);
11257 local++; 11257 local++;
11258 } 11258 }
11259 } 11259 }
11260 11260
11261 // Check whether this frame is positioned at return. If not top 11261 // Check whether this frame is positioned at return. If not top
11262 // frame or if the frame is optimized it cannot be at a return. 11262 // frame or if the frame is optimized it cannot be at a return.
11263 bool at_return = false; 11263 bool at_return = false;
11264 if (!is_optimized && index == 0) { 11264 if (!is_optimized && index == 0) {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
11416 } 11416 }
11417 } 11417 }
11418 details->set(kFrameDetailsReceiverIndex, *receiver); 11418 details->set(kFrameDetailsReceiverIndex, *receiver);
11419 11419
11420 ASSERT_EQ(details_size, details_index); 11420 ASSERT_EQ(details_size, details_index);
11421 return *isolate->factory()->NewJSArrayWithElements(details); 11421 return *isolate->factory()->NewJSArrayWithElements(details);
11422 } 11422 }
11423 11423
11424 11424
11425 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info, 11425 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
11426 int index) { 11426 Handle<String> parameter_name) {
11427 VariableMode mode; 11427 VariableMode mode;
11428 InitializationFlag flag; 11428 InitializationFlag flag;
11429 return info->ContextSlotIndex(info->ParameterName(index), &mode, &flag) != -1; 11429 return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &flag) != -1;
11430 } 11430 }
11431 11431
11432 11432
11433 // Create a plain JSObject which materializes the local scope for the specified 11433 // Create a plain JSObject which materializes the local scope for the specified
11434 // frame. 11434 // frame.
11435 MUST_USE_RESULT 11435 MUST_USE_RESULT
11436 static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector( 11436 static MaybeHandle<JSObject> MaterializeStackLocalsWithFrameInspector(
11437 Isolate* isolate, 11437 Isolate* isolate,
11438 Handle<JSObject> target, 11438 Handle<JSObject> target,
11439 Handle<JSFunction> function, 11439 Handle<JSFunction> function,
11440 FrameInspector* frame_inspector) { 11440 FrameInspector* frame_inspector) {
11441 Handle<SharedFunctionInfo> shared(function->shared()); 11441 Handle<SharedFunctionInfo> shared(function->shared());
11442 Handle<ScopeInfo> scope_info(shared->scope_info()); 11442 Handle<ScopeInfo> scope_info(shared->scope_info());
11443 11443
11444 // First fill all parameters. 11444 // First fill all parameters.
11445 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 11445 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
11446 // Do not materialize the parameter if it is shadowed by a context local. 11446 // Do not materialize the parameter if it is shadowed by a context local.
11447 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; 11447 Handle<String> name(scope_info->ParameterName(i));
11448 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue;
11448 11449
11449 HandleScope scope(isolate); 11450 HandleScope scope(isolate);
11450 Handle<Object> value(i < frame_inspector->GetParametersCount() 11451 Handle<Object> value(i < frame_inspector->GetParametersCount()
11451 ? frame_inspector->GetParameter(i) 11452 ? frame_inspector->GetParameter(i)
11452 : isolate->heap()->undefined_value(), 11453 : isolate->heap()->undefined_value(),
11453 isolate); 11454 isolate);
11454 ASSERT(!value->IsTheHole()); 11455 ASSERT(!value->IsTheHole());
11455 Handle<String> name(scope_info->ParameterName(i));
11456 11456
11457 RETURN_ON_EXCEPTION( 11457 RETURN_ON_EXCEPTION(
11458 isolate, 11458 isolate,
11459 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY), 11459 Runtime::SetObjectProperty(isolate, target, name, value, NONE, SLOPPY),
11460 JSObject); 11460 JSObject);
11461 } 11461 }
11462 11462
11463 // Second fill all stack locals. 11463 // Second fill all stack locals.
11464 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11464 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11465 if (scope_info->LocalIsSynthetic(i)) continue; 11465 if (scope_info->LocalIsSynthetic(i)) continue;
(...skipping 22 matching lines...) Expand all
11488 // and assert that this cannot happen. 11488 // and assert that this cannot happen.
11489 return; 11489 return;
11490 } 11490 }
11491 11491
11492 Handle<SharedFunctionInfo> shared(function->shared()); 11492 Handle<SharedFunctionInfo> shared(function->shared());
11493 Handle<ScopeInfo> scope_info(shared->scope_info()); 11493 Handle<ScopeInfo> scope_info(shared->scope_info());
11494 11494
11495 // Parameters. 11495 // Parameters.
11496 for (int i = 0; i < scope_info->ParameterCount(); ++i) { 11496 for (int i = 0; i < scope_info->ParameterCount(); ++i) {
11497 // Shadowed parameters were not materialized. 11497 // Shadowed parameters were not materialized.
11498 if (ParameterIsShadowedByContextLocal(scope_info, i)) continue; 11498 Handle<String> name(scope_info->ParameterName(i));
11499 if (ParameterIsShadowedByContextLocal(scope_info, name)) continue;
11499 11500
11500 ASSERT(!frame->GetParameter(i)->IsTheHole()); 11501 ASSERT(!frame->GetParameter(i)->IsTheHole());
11501 HandleScope scope(isolate); 11502 HandleScope scope(isolate);
11502 Handle<String> name(scope_info->ParameterName(i));
11503 Handle<Object> value = 11503 Handle<Object> value =
11504 Object::GetPropertyOrElement(target, name).ToHandleChecked(); 11504 Object::GetPropertyOrElement(target, name).ToHandleChecked();
11505 frame->SetParameterValue(i, *value); 11505 frame->SetParameterValue(i, *value);
11506 } 11506 }
11507 11507
11508 // Stack locals. 11508 // Stack locals.
11509 for (int i = 0; i < scope_info->StackLocalCount(); ++i) { 11509 for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
11510 if (scope_info->LocalIsSynthetic(i)) continue; 11510 if (scope_info->LocalIsSynthetic(i)) continue;
11511 if (frame->GetExpression(i)->IsTheHole()) continue; 11511 if (frame->GetExpression(i)->IsTheHole()) continue;
11512 HandleScope scope(isolate); 11512 HandleScope scope(isolate);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
11593 Handle<ScopeInfo> scope_info, 11593 Handle<ScopeInfo> scope_info,
11594 Handle<Context> context, 11594 Handle<Context> context,
11595 Handle<String> variable_name, 11595 Handle<String> variable_name,
11596 Handle<Object> new_value) { 11596 Handle<Object> new_value) {
11597 for (int i = 0; i < scope_info->ContextLocalCount(); i++) { 11597 for (int i = 0; i < scope_info->ContextLocalCount(); i++) {
11598 Handle<String> next_name(scope_info->ContextLocalName(i)); 11598 Handle<String> next_name(scope_info->ContextLocalName(i));
11599 if (String::Equals(variable_name, next_name)) { 11599 if (String::Equals(variable_name, next_name)) {
11600 VariableMode mode; 11600 VariableMode mode;
11601 InitializationFlag init_flag; 11601 InitializationFlag init_flag;
11602 int context_index = 11602 int context_index =
11603 scope_info->ContextSlotIndex(*next_name, &mode, &init_flag); 11603 ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &init_flag);
11604 context->set(context_index, *new_value); 11604 context->set(context_index, *new_value);
11605 return true; 11605 return true;
11606 } 11606 }
11607 } 11607 }
11608 11608
11609 return false; 11609 return false;
11610 } 11610 }
11611 11611
11612 11612
11613 static bool SetLocalVariableValue(Isolate* isolate, 11613 static bool SetLocalVariableValue(Isolate* isolate,
(...skipping 3525 matching lines...) Expand 10 before | Expand all | Expand 10 after
15139 } 15139 }
15140 return NULL; 15140 return NULL;
15141 } 15141 }
15142 15142
15143 15143
15144 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) { 15144 const Runtime::Function* Runtime::FunctionForId(Runtime::FunctionId id) {
15145 return &(kIntrinsicFunctions[static_cast<int>(id)]); 15145 return &(kIntrinsicFunctions[static_cast<int>(id)]);
15146 } 15146 }
15147 15147
15148 } } // namespace v8::internal 15148 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/scopeinfo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698