Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 2351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2362 AddInstruction(call->PushArgumentAt(i)); | 2362 AddInstruction(call->PushArgumentAt(i)); |
| 2363 } | 2363 } |
| 2364 } | 2364 } |
| 2365 | 2365 |
| 2366 | 2366 |
| 2367 void HGraphBuilder::SetupScope(Scope* scope) { | 2367 void HGraphBuilder::SetupScope(Scope* scope) { |
| 2368 // We don't yet handle the function name for named function expressions. | 2368 // We don't yet handle the function name for named function expressions. |
| 2369 if (scope->function() != NULL) BAILOUT("named function expression"); | 2369 if (scope->function() != NULL) BAILOUT("named function expression"); |
| 2370 | 2370 |
| 2371 // We can't handle heap-allocated locals. | 2371 // We can't handle heap-allocated locals. |
| 2372 if (scope->num_heap_slots() > 0) BAILOUT("heap allocated locals"); | 2372 if (scope->num_heap_slots() > 0) BAILOUT("heap allocated locals"); |
|
fschneider
2010/12/13 19:00:18
I think this bailout can go away, too.
antonm
2010/12/13 22:41:04
I am not sure. Apparently it makes us bail out of
| |
| 2373 | 2373 |
| 2374 HConstant* undefined_constant = | 2374 HConstant* undefined_constant = |
| 2375 new HConstant(Factory::undefined_value(), Representation::Tagged()); | 2375 new HConstant(Factory::undefined_value(), Representation::Tagged()); |
| 2376 AddInstruction(undefined_constant); | 2376 AddInstruction(undefined_constant); |
| 2377 graph_->set_undefined_constant(undefined_constant); | 2377 graph_->set_undefined_constant(undefined_constant); |
| 2378 | 2378 |
| 2379 // Set the initial values of parameters including "this". "This" has | 2379 // Set the initial values of parameters including "this". "This" has |
| 2380 // parameter index 0. | 2380 // parameter index 0. |
| 2381 int count = scope->num_parameters() + 1; | 2381 int count = scope->num_parameters() + 1; |
| 2382 for (int i = 0; i < count; ++i) { | 2382 for (int i = 0; i < count; ++i) { |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2923 | 2923 |
| 2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { | 2924 void HGraphBuilder::VisitVariableProxy(VariableProxy* expr) { |
| 2925 Variable* variable = expr->AsVariable(); | 2925 Variable* variable = expr->AsVariable(); |
| 2926 if (variable == NULL) { | 2926 if (variable == NULL) { |
| 2927 BAILOUT("reference to rewritten variable"); | 2927 BAILOUT("reference to rewritten variable"); |
| 2928 } else if (variable->IsStackAllocated()) { | 2928 } else if (variable->IsStackAllocated()) { |
| 2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { | 2929 if (environment()->Lookup(variable)->CheckFlag(HValue::kIsArguments)) { |
| 2930 BAILOUT("unsupported context for arguments object"); | 2930 BAILOUT("unsupported context for arguments object"); |
| 2931 } | 2931 } |
| 2932 ast_context()->ReturnValue(environment()->Lookup(variable)); | 2932 ast_context()->ReturnValue(environment()->Lookup(variable)); |
| 2933 } else if (variable->AsSlot() != NULL && | |
| 2934 variable->AsSlot()->type() == Slot::CONTEXT) { | |
|
fschneider
2010/12/13 19:00:18
Indentation.
antonm
2010/12/13 22:41:04
Done.
| |
| 2935 if (variable->mode() == Variable::CONST) { | |
| 2936 BAILOUT("reference to const context slot"); | |
| 2937 } | |
| 2938 Slot* slot = variable->AsSlot(); | |
| 2939 CompilationInfo* info = graph()->info(); | |
| 2940 int context_chain_length = info->function()->scope()-> | |
| 2941 ContextChainLength(slot->var()->scope()); | |
| 2942 ASSERT(context_chain_length >= 0); | |
| 2943 Handle<JSFunction> closure = info->closure(); | |
| 2944 Context* context = closure->context(); | |
| 2945 for (int i = 0; i < context_chain_length; i++) { | |
| 2946 context = context->closure()->context(); | |
| 2947 } | |
| 2948 // TODO(antonm): if slot's value is not modified by closures, instead | |
| 2949 // of reading it out of context, we could just embed the value as | |
| 2950 // a constant. | |
| 2951 HLoadContextSlot* instr = | |
| 2952 new HLoadContextSlot(Handle<Context>(context), slot->index()); | |
| 2953 ast_context()->ReturnInstruction(instr, expr->id()); | |
| 2933 } else if (variable->is_global()) { | 2954 } else if (variable->is_global()) { |
| 2934 LookupResult lookup; | 2955 LookupResult lookup; |
| 2935 LookupGlobalPropertyCell(variable, &lookup, false); | 2956 LookupGlobalPropertyCell(variable, &lookup, false); |
| 2936 CHECK_BAILOUT; | 2957 CHECK_BAILOUT; |
| 2937 | 2958 |
| 2938 Handle<GlobalObject> global(graph()->info()->global_object()); | 2959 Handle<GlobalObject> global(graph()->info()->global_object()); |
| 2939 // TODO(3039103): Handle global property load through an IC call when access | 2960 // TODO(3039103): Handle global property load through an IC call when access |
| 2940 // checks are enabled. | 2961 // checks are enabled. |
| 2941 if (global->IsAccessCheckNeeded()) { | 2962 if (global->IsAccessCheckNeeded()) { |
| 2942 BAILOUT("global object requires access check"); | 2963 BAILOUT("global object requires access check"); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3434 | 3455 |
| 3435 if (expr->is_compound()) { | 3456 if (expr->is_compound()) { |
| 3436 HandleCompoundAssignment(expr); | 3457 HandleCompoundAssignment(expr); |
| 3437 return; | 3458 return; |
| 3438 } | 3459 } |
| 3439 | 3460 |
| 3440 if (var != NULL) { | 3461 if (var != NULL) { |
| 3441 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); | 3462 if (proxy->IsArguments()) BAILOUT("assignment to arguments"); |
| 3442 | 3463 |
| 3443 // Handle the assignment. | 3464 // Handle the assignment. |
| 3465 if (var->AsSlot() != NULL && var->AsSlot()->type() == Slot::CONTEXT) { | |
| 3466 BAILOUT("context slot assignment"); | |
| 3467 } | |
| 3444 if (var->is_global()) { | 3468 if (var->is_global()) { |
| 3445 VISIT_FOR_VALUE(expr->value()); | 3469 VISIT_FOR_VALUE(expr->value()); |
| 3446 HandleGlobalVariableAssignment(var, Top(), expr->position(), expr->id()); | 3470 HandleGlobalVariableAssignment(var, Top(), expr->position(), expr->id()); |
| 3447 } else { | 3471 } else { |
| 3448 // We allow reference to the arguments object only in assignemtns | 3472 // We allow reference to the arguments object only in assignemtns |
| 3449 // to local variables to make sure that the arguments object does | 3473 // to local variables to make sure that the arguments object does |
| 3450 // not escape and is not modified. | 3474 // not escape and is not modified. |
| 3451 VariableProxy* rhs = expr->value()->AsVariableProxy(); | 3475 VariableProxy* rhs = expr->value()->AsVariableProxy(); |
| 3452 if (rhs != NULL && | 3476 if (rhs != NULL && |
| 3453 rhs->var()->IsStackAllocated() && | 3477 rhs->var()->IsStackAllocated() && |
| (...skipping 2211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5665 } | 5689 } |
| 5666 | 5690 |
| 5667 #ifdef DEBUG | 5691 #ifdef DEBUG |
| 5668 if (graph_ != NULL) graph_->Verify(); | 5692 if (graph_ != NULL) graph_->Verify(); |
| 5669 if (chunk_ != NULL) chunk_->Verify(); | 5693 if (chunk_ != NULL) chunk_->Verify(); |
| 5670 if (allocator_ != NULL) allocator_->Verify(); | 5694 if (allocator_ != NULL) allocator_->Verify(); |
| 5671 #endif | 5695 #endif |
| 5672 } | 5696 } |
| 5673 | 5697 |
| 5674 } } // namespace v8::internal | 5698 } } // namespace v8::internal |
| OLD | NEW |