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

Side by Side Diff: src/hydrogen.cc

Issue 10828049: Move some Pop/Drop calls directly to the places where they are needed. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Moved HCheckNonSmi Created 8 years, 4 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 | « no previous file | 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 5084 matching lines...) Expand 10 before | Expand all | Expand 10 after
5095 } else if (is_monomorphic_field) { 5095 } else if (is_monomorphic_field) {
5096 is_monomorphic_field = (offset == previous_field_offset) && 5096 is_monomorphic_field = (offset == previous_field_offset) &&
5097 (is_in_object == previous_field_is_in_object); 5097 (is_in_object == previous_field_is_in_object);
5098 } 5098 }
5099 ++count; 5099 ++count;
5100 } 5100 }
5101 } 5101 }
5102 5102
5103 // Use monomorphic load if property lookup results in the same field index 5103 // Use monomorphic load if property lookup results in the same field index
5104 // for all maps. Requires special map check on the set of all handled maps. 5104 // for all maps. Requires special map check on the set of all handled maps.
5105 AddInstruction(new(zone()) HCheckNonSmi(object));
5105 HInstruction* instr; 5106 HInstruction* instr;
5106 if (count == types->length() && is_monomorphic_field) { 5107 if (count == types->length() && is_monomorphic_field) {
5107 AddInstruction(new(zone()) HCheckMaps(object, types, zone())); 5108 AddInstruction(new(zone()) HCheckMaps(object, types, zone()));
5108 instr = BuildLoadNamedField(object, map, &lookup, false); 5109 instr = BuildLoadNamedField(object, map, &lookup, false);
5109 } else { 5110 } else {
5110 HValue* context = environment()->LookupContext(); 5111 HValue* context = environment()->LookupContext();
5111 instr = new(zone()) HLoadNamedFieldPolymorphic(context, 5112 instr = new(zone()) HLoadNamedFieldPolymorphic(context,
5112 object, 5113 object,
5113 types, 5114 types,
5114 name, 5115 name,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
5195 if (!ast_context()->IsEffect()) return ast_context()->ReturnValue(Pop()); 5196 if (!ast_context()->IsEffect()) return ast_context()->ReturnValue(Pop());
5196 } 5197 }
5197 5198
5198 5199
5199 void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) { 5200 void HGraphBuilder::HandlePropertyAssignment(Assignment* expr) {
5200 Property* prop = expr->target()->AsProperty(); 5201 Property* prop = expr->target()->AsProperty();
5201 ASSERT(prop != NULL); 5202 ASSERT(prop != NULL);
5202 expr->RecordTypeFeedback(oracle(), zone()); 5203 expr->RecordTypeFeedback(oracle(), zone());
5203 CHECK_ALIVE(VisitForValue(prop->obj())); 5204 CHECK_ALIVE(VisitForValue(prop->obj()));
5204 5205
5205 HValue* value = NULL;
5206 HInstruction* instr = NULL;
5207
5208 if (prop->key()->IsPropertyName()) { 5206 if (prop->key()->IsPropertyName()) {
5209 // Named store. 5207 // Named store.
5210 CHECK_ALIVE(VisitForValue(expr->value())); 5208 CHECK_ALIVE(VisitForValue(expr->value()));
5211 value = Pop(); 5209 HValue* value = environment()->ExpressionStackAt(0);
5212 HValue* object = Pop(); 5210 HValue* object = environment()->ExpressionStackAt(1);
5213 5211
5214 Literal* key = prop->key()->AsLiteral(); 5212 Literal* key = prop->key()->AsLiteral();
5215 Handle<String> name = Handle<String>::cast(key->handle()); 5213 Handle<String> name = Handle<String>::cast(key->handle());
5216 ASSERT(!name.is_null()); 5214 ASSERT(!name.is_null());
5217 5215
5216 HInstruction* instr = NULL;
5218 SmallMapList* types = expr->GetReceiverTypes(); 5217 SmallMapList* types = expr->GetReceiverTypes();
5219 if (expr->IsMonomorphic()) { 5218 if (expr->IsMonomorphic()) {
5220 Handle<Map> map = types->first(); 5219 Handle<Map> map = types->first();
5221 Handle<AccessorPair> accessors; 5220 Handle<AccessorPair> accessors;
5222 Handle<JSObject> holder; 5221 Handle<JSObject> holder;
5223 if (LookupAccessorPair(map, name, &accessors, &holder)) { 5222 if (LookupAccessorPair(map, name, &accessors, &holder)) {
5223 Drop(2);
5224 instr = BuildCallSetter(object, value, map, accessors, holder); 5224 instr = BuildCallSetter(object, value, map, accessors, holder);
5225 } else { 5225 } else {
5226 Drop(2);
5226 CHECK_ALIVE(instr = BuildStoreNamedMonomorphic(object, 5227 CHECK_ALIVE(instr = BuildStoreNamedMonomorphic(object,
5227 name, 5228 name,
5228 value, 5229 value,
5229 map)); 5230 map));
5230 } 5231 }
5232
5231 } else if (types != NULL && types->length() > 1) { 5233 } else if (types != NULL && types->length() > 1) {
5232 HandlePolymorphicStoreNamedField(expr, object, value, types, name); 5234 Drop(2);
5233 return; 5235 return HandlePolymorphicStoreNamedField(expr, object, value, types, name);
5234
5235 } else { 5236 } else {
5237 Drop(2);
5236 instr = BuildStoreNamedGeneric(object, name, value); 5238 instr = BuildStoreNamedGeneric(object, name, value);
5237 } 5239 }
5238 5240
5241 Push(value);
5242 instr->set_position(expr->position());
5243 AddInstruction(instr);
5244 if (instr->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
5245 return ast_context()->ReturnValue(Pop());
5246
5239 } else { 5247 } else {
5240 // Keyed store. 5248 // Keyed store.
5241 CHECK_ALIVE(VisitForValue(prop->key())); 5249 CHECK_ALIVE(VisitForValue(prop->key()));
5242 CHECK_ALIVE(VisitForValue(expr->value())); 5250 CHECK_ALIVE(VisitForValue(expr->value()));
5243 value = Pop(); 5251 HValue* value = Pop();
5244 HValue* key = Pop(); 5252 HValue* key = Pop();
5245 HValue* object = Pop(); 5253 HValue* object = Pop();
5246 bool has_side_effects = false; 5254 bool has_side_effects = false;
5247 HandleKeyedElementAccess(object, key, value, expr, expr->AssignmentId(), 5255 HandleKeyedElementAccess(object, key, value, expr, expr->AssignmentId(),
5248 expr->position(), 5256 expr->position(),
5249 true, // is_store 5257 true, // is_store
5250 &has_side_effects); 5258 &has_side_effects);
5251 Push(value); 5259 Push(value);
5252 ASSERT(has_side_effects); // Stores always have side effects. 5260 ASSERT(has_side_effects); // Stores always have side effects.
5253 AddSimulate(expr->AssignmentId()); 5261 AddSimulate(expr->AssignmentId());
5254 return ast_context()->ReturnValue(Pop()); 5262 return ast_context()->ReturnValue(Pop());
5255 } 5263 }
5256 Push(value);
5257 instr->set_position(expr->position());
5258 AddInstruction(instr);
5259 if (instr->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
5260 return ast_context()->ReturnValue(Pop());
5261 } 5264 }
5262 5265
5263 5266
5264 // Because not every expression has a position and there is not common 5267 // Because not every expression has a position and there is not common
5265 // superclass of Assignment and CountOperation, we cannot just pass the 5268 // superclass of Assignment and CountOperation, we cannot just pass the
5266 // owning expression instead of position and ast_id separately. 5269 // owning expression instead of position and ast_id separately.
5267 void HGraphBuilder::HandleGlobalVariableAssignment(Variable* var, 5270 void HGraphBuilder::HandleGlobalVariableAssignment(Variable* var,
5268 HValue* value, 5271 HValue* value,
5269 int position, 5272 int position,
5270 int ast_id) { 5273 int ast_id) {
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
6337 6340
6338 } else if (expr->IsFunctionPrototype()) { 6341 } else if (expr->IsFunctionPrototype()) {
6339 HValue* function = Pop(); 6342 HValue* function = Pop();
6340 AddInstruction(new(zone()) HCheckNonSmi(function)); 6343 AddInstruction(new(zone()) HCheckNonSmi(function));
6341 instr = new(zone()) HLoadFunctionPrototype(function); 6344 instr = new(zone()) HLoadFunctionPrototype(function);
6342 6345
6343 } else if (expr->key()->IsPropertyName()) { 6346 } else if (expr->key()->IsPropertyName()) {
6344 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); 6347 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
6345 SmallMapList* types = expr->GetReceiverTypes(); 6348 SmallMapList* types = expr->GetReceiverTypes();
6346 6349
6347 HValue* obj = Pop();
6348 if (expr->IsMonomorphic()) { 6350 if (expr->IsMonomorphic()) {
6349 Handle<Map> map = types->first(); 6351 Handle<Map> map = types->first();
6350 Handle<AccessorPair> accessors; 6352 Handle<AccessorPair> accessors;
6351 Handle<JSObject> holder; 6353 Handle<JSObject> holder;
6352 if (LookupAccessorPair(map, name, &accessors, &holder)) { 6354 if (LookupAccessorPair(map, name, &accessors, &holder)) {
6353 instr = BuildCallGetter(obj, map, accessors, holder); 6355 instr = BuildCallGetter(Pop(), map, accessors, holder);
6354 } else { 6356 } else {
6355 instr = BuildLoadNamedMonomorphic(obj, name, expr, map); 6357 instr = BuildLoadNamedMonomorphic(Pop(), name, expr, map);
6356 } 6358 }
6357 } else if (types != NULL && types->length() > 1) { 6359 } else if (types != NULL && types->length() > 1) {
6358 AddInstruction(new(zone()) HCheckNonSmi(obj)); 6360 return HandlePolymorphicLoadNamedField(expr, Pop(), types, name);
6359 HandlePolymorphicLoadNamedField(expr, obj, types, name);
6360 return;
6361 } else { 6361 } else {
6362 instr = BuildLoadNamedGeneric(obj, name, expr); 6362 instr = BuildLoadNamedGeneric(Pop(), name, expr);
6363 } 6363 }
6364 6364
6365 } else { 6365 } else {
6366 CHECK_ALIVE(VisitForValue(expr->key())); 6366 CHECK_ALIVE(VisitForValue(expr->key()));
6367 6367
6368 HValue* key = Pop(); 6368 HValue* key = Pop();
6369 HValue* obj = Pop(); 6369 HValue* obj = Pop();
6370 6370
6371 bool has_side_effects = false; 6371 bool has_side_effects = false;
6372 HValue* load = HandleKeyedElementAccess( 6372 HValue* load = HandleKeyedElementAccess(
(...skipping 3270 matching lines...) Expand 10 before | Expand all | Expand 10 after
9643 } 9643 }
9644 } 9644 }
9645 9645
9646 #ifdef DEBUG 9646 #ifdef DEBUG
9647 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9647 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9648 if (allocator_ != NULL) allocator_->Verify(); 9648 if (allocator_ != NULL) allocator_->Verify();
9649 #endif 9649 #endif
9650 } 9650 }
9651 9651
9652 } } // namespace v8::internal 9652 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698