| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 4957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4968 HandlePolymorphicCallNamed(expr, receiver, types, name); | 4968 HandlePolymorphicCallNamed(expr, receiver, types, name); |
| 4969 return; | 4969 return; |
| 4970 | 4970 |
| 4971 } else { | 4971 } else { |
| 4972 HValue* context = environment()->LookupContext(); | 4972 HValue* context = environment()->LookupContext(); |
| 4973 call = PreProcessCall( | 4973 call = PreProcessCall( |
| 4974 new(zone()) HCallNamed(context, name, argument_count)); | 4974 new(zone()) HCallNamed(context, name, argument_count)); |
| 4975 } | 4975 } |
| 4976 | 4976 |
| 4977 } else { | 4977 } else { |
| 4978 expr->RecordTypeFeedback(oracle(), CALL_AS_FUNCTION); |
| 4978 VariableProxy* proxy = expr->expression()->AsVariableProxy(); | 4979 VariableProxy* proxy = expr->expression()->AsVariableProxy(); |
| 4979 bool global_call = proxy != NULL && proxy->var()->IsUnallocated(); | 4980 bool global_call = proxy != NULL && proxy->var()->IsUnallocated(); |
| 4980 | 4981 |
| 4981 if (global_call) { | 4982 if (global_call) { |
| 4982 Variable* var = proxy->var(); | 4983 Variable* var = proxy->var(); |
| 4983 bool known_global_function = false; | 4984 bool known_global_function = false; |
| 4984 // If there is a global property cell for the name at compile time and | 4985 // If there is a global property cell for the name at compile time and |
| 4985 // access check is not enabled we assume that the function will not change | 4986 // access check is not enabled we assume that the function will not change |
| 4986 // and generate optimized code for calling the function. | 4987 // and generate optimized code for calling the function. |
| 4987 LookupResult lookup; | 4988 LookupResult lookup; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5020 HValue* context = environment()->LookupContext(); | 5021 HValue* context = environment()->LookupContext(); |
| 5021 HGlobalObject* receiver = new(zone()) HGlobalObject(context); | 5022 HGlobalObject* receiver = new(zone()) HGlobalObject(context); |
| 5022 AddInstruction(receiver); | 5023 AddInstruction(receiver); |
| 5023 PushAndAdd(new(zone()) HPushArgument(receiver)); | 5024 PushAndAdd(new(zone()) HPushArgument(receiver)); |
| 5024 CHECK_ALIVE(VisitArgumentList(expr->arguments())); | 5025 CHECK_ALIVE(VisitArgumentList(expr->arguments())); |
| 5025 | 5026 |
| 5026 call = new(zone()) HCallGlobal(context, var->name(), argument_count); | 5027 call = new(zone()) HCallGlobal(context, var->name(), argument_count); |
| 5027 Drop(argument_count); | 5028 Drop(argument_count); |
| 5028 } | 5029 } |
| 5029 | 5030 |
| 5031 } else if (expr->IsMonomorphic()) { |
| 5032 // The function is on the stack in the unoptimized code during |
| 5033 // evaluation of the arguments. |
| 5034 CHECK_ALIVE(VisitForValue(expr->expression())); |
| 5035 HValue* function = Top(); |
| 5036 HValue* context = environment()->LookupContext(); |
| 5037 HGlobalObject* global = new(zone()) HGlobalObject(context); |
| 5038 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global); |
| 5039 AddInstruction(global); |
| 5040 PushAndAdd(receiver); |
| 5041 CHECK_ALIVE(VisitExpressions(expr->arguments())); |
| 5042 AddInstruction(new(zone()) HCheckFunction(function, expr->target())); |
| 5043 if (TryInline(expr)) { |
| 5044 // The function is lingering in the deoptimization environment. |
| 5045 // Handle it by case analysis on the AST context. |
| 5046 if (ast_context()->IsEffect()) { |
| 5047 Drop(1); |
| 5048 } else if (ast_context()->IsValue()) { |
| 5049 HValue* result = Pop(); |
| 5050 Drop(1); |
| 5051 Push(result); |
| 5052 } else if (ast_context()->IsTest()) { |
| 5053 TestContext* context = TestContext::cast(ast_context()); |
| 5054 if (context->if_true()->HasPredecessor()) { |
| 5055 context->if_true()->last_environment()->Drop(1); |
| 5056 } |
| 5057 if (context->if_false()->HasPredecessor()) { |
| 5058 context->if_true()->last_environment()->Drop(1); |
| 5059 } |
| 5060 } else { |
| 5061 UNREACHABLE(); |
| 5062 } |
| 5063 return; |
| 5064 } else { |
| 5065 call = PreProcessCall(new(zone()) HInvokeFunction(context, |
| 5066 function, |
| 5067 argument_count)); |
| 5068 Drop(1); // The function. |
| 5069 } |
| 5070 |
| 5030 } else { | 5071 } else { |
| 5031 CHECK_ALIVE(VisitArgument(expr->expression())); | 5072 CHECK_ALIVE(VisitArgument(expr->expression())); |
| 5032 HValue* context = environment()->LookupContext(); | 5073 HValue* context = environment()->LookupContext(); |
| 5033 HGlobalObject* global_object = new(zone()) HGlobalObject(context); | 5074 HGlobalObject* global_object = new(zone()) HGlobalObject(context); |
| 5034 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global_object); | 5075 HGlobalReceiver* receiver = new(zone()) HGlobalReceiver(global_object); |
| 5035 AddInstruction(global_object); | 5076 AddInstruction(global_object); |
| 5036 AddInstruction(receiver); | 5077 AddInstruction(receiver); |
| 5037 PushAndAdd(new(zone()) HPushArgument(receiver)); | 5078 PushAndAdd(new(zone()) HPushArgument(receiver)); |
| 5038 CHECK_ALIVE(VisitArgumentList(expr->arguments())); | 5079 CHECK_ALIVE(VisitArgumentList(expr->arguments())); |
| 5039 | 5080 |
| (...skipping 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6869 } | 6910 } |
| 6870 } | 6911 } |
| 6871 | 6912 |
| 6872 #ifdef DEBUG | 6913 #ifdef DEBUG |
| 6873 if (graph_ != NULL) graph_->Verify(false); // No full verify. | 6914 if (graph_ != NULL) graph_->Verify(false); // No full verify. |
| 6874 if (allocator_ != NULL) allocator_->Verify(); | 6915 if (allocator_ != NULL) allocator_->Verify(); |
| 6875 #endif | 6916 #endif |
| 6876 } | 6917 } |
| 6877 | 6918 |
| 6878 } } // namespace v8::internal | 6919 } } // namespace v8::internal |
| OLD | NEW |