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

Side by Side Diff: src/hydrogen.cc

Issue 10826028: Cleaned up Hydrogen function signatures related to property access. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed feedback 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 | « src/hydrogen.h ('k') | 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 4746 matching lines...) Expand 10 before | Expand all | Expand 10 after
4757 switch (property->kind()) { 4757 switch (property->kind()) {
4758 case ObjectLiteral::Property::MATERIALIZED_LITERAL: 4758 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
4759 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); 4759 ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
4760 // Fall through. 4760 // Fall through.
4761 case ObjectLiteral::Property::COMPUTED: 4761 case ObjectLiteral::Property::COMPUTED:
4762 if (key->handle()->IsSymbol()) { 4762 if (key->handle()->IsSymbol()) {
4763 if (property->emit_store()) { 4763 if (property->emit_store()) {
4764 property->RecordTypeFeedback(oracle()); 4764 property->RecordTypeFeedback(oracle());
4765 CHECK_ALIVE(VisitForValue(value)); 4765 CHECK_ALIVE(VisitForValue(value));
4766 HValue* value = Pop(); 4766 HValue* value = Pop();
4767 Handle<String> name = property->key()->AsPropertyName();
4767 HInstruction* store; 4768 HInstruction* store;
4768 CHECK_ALIVE(store = BuildStoreNamed(literal, 4769 CHECK_ALIVE(store = BuildStoreNamed(literal,
4770 name,
4769 value, 4771 value,
4770 property->GetReceiverType(), 4772 property->GetReceiverType()));
4771 property->key()));
4772 AddInstruction(store); 4773 AddInstruction(store);
4773 if (store->HasObservableSideEffects()) AddSimulate(key->id()); 4774 if (store->HasObservableSideEffects()) AddSimulate(key->id());
4774 } else { 4775 } else {
4775 CHECK_ALIVE(VisitForEffect(value)); 4776 CHECK_ALIVE(VisitForEffect(value));
4776 } 4777 }
4777 break; 4778 break;
4778 } 4779 }
4779 // Fall through. 4780 // Fall through.
4780 case ObjectLiteral::Property::PROTOTYPE: 4781 case ObjectLiteral::Property::PROTOTYPE:
4781 case ObjectLiteral::Property::SETTER: 4782 case ObjectLiteral::Property::SETTER:
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
4932 } else { 4933 } else {
4933 Map* transition = lookup->GetTransitionMapFromMap(*type); 4934 Map* transition = lookup->GetTransitionMapFromMap(*type);
4934 return transition->PropertyIndexFor(*name) - type->inobject_properties(); 4935 return transition->PropertyIndexFor(*name) - type->inobject_properties();
4935 } 4936 }
4936 } 4937 }
4937 4938
4938 4939
4939 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object, 4940 HInstruction* HGraphBuilder::BuildStoreNamedField(HValue* object,
4940 Handle<String> name, 4941 Handle<String> name,
4941 HValue* value, 4942 HValue* value,
4942 Handle<Map> type, 4943 Handle<Map> map,
4943 LookupResult* lookup, 4944 LookupResult* lookup,
4944 bool smi_and_map_check) { 4945 bool smi_and_map_check) {
4945 ASSERT(lookup->IsFound()); 4946 ASSERT(lookup->IsFound());
4946 if (smi_and_map_check) { 4947 if (smi_and_map_check) {
4947 AddInstruction(new(zone()) HCheckNonSmi(object)); 4948 AddInstruction(new(zone()) HCheckNonSmi(object));
4948 AddInstruction(HCheckMaps::NewWithTransitions(object, type, zone())); 4949 AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone()));
4949 } 4950 }
4950 4951
4951 // If the property does not exist yet, we have to check that it wasn't made 4952 // If the property does not exist yet, we have to check that it wasn't made
4952 // readonly or turned into a setter by some meanwhile modifications on the 4953 // readonly or turned into a setter by some meanwhile modifications on the
4953 // prototype chain. 4954 // prototype chain.
4954 if (!lookup->IsProperty() && type->prototype()->IsJSReceiver()) { 4955 if (!lookup->IsProperty() && map->prototype()->IsJSReceiver()) {
4955 Object* proto = type->prototype(); 4956 Object* proto = map->prototype();
4956 // First check that the prototype chain isn't affected already. 4957 // First check that the prototype chain isn't affected already.
4957 LookupResult proto_result(isolate()); 4958 LookupResult proto_result(isolate());
4958 proto->Lookup(*name, &proto_result); 4959 proto->Lookup(*name, &proto_result);
4959 if (proto_result.IsProperty()) { 4960 if (proto_result.IsProperty()) {
4960 // If the inherited property could induce readonly-ness, bail out. 4961 // If the inherited property could induce readonly-ness, bail out.
4961 if (proto_result.IsReadOnly() || !proto_result.IsCacheable()) { 4962 if (proto_result.IsReadOnly() || !proto_result.IsCacheable()) {
4962 Bailout("improper object on prototype chain for store"); 4963 Bailout("improper object on prototype chain for store");
4963 return NULL; 4964 return NULL;
4964 } 4965 }
4965 // We only need to check up to the preexisting property. 4966 // We only need to check up to the preexisting property.
4966 proto = proto_result.holder(); 4967 proto = proto_result.holder();
4967 } else { 4968 } else {
4968 // Otherwise, find the top prototype. 4969 // Otherwise, find the top prototype.
4969 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype(); 4970 while (proto->GetPrototype()->IsJSObject()) proto = proto->GetPrototype();
4970 ASSERT(proto->GetPrototype()->IsNull()); 4971 ASSERT(proto->GetPrototype()->IsNull());
4971 } 4972 }
4972 ASSERT(proto->IsJSObject()); 4973 ASSERT(proto->IsJSObject());
4973 AddInstruction(new(zone()) HCheckPrototypeMaps( 4974 AddInstruction(new(zone()) HCheckPrototypeMaps(
4974 Handle<JSObject>(JSObject::cast(type->prototype())), 4975 Handle<JSObject>(JSObject::cast(map->prototype())),
4975 Handle<JSObject>(JSObject::cast(proto)))); 4976 Handle<JSObject>(JSObject::cast(proto))));
4976 } 4977 }
4977 4978
4978 int index = ComputeLoadStoreFieldIndex(type, name, lookup); 4979 int index = ComputeLoadStoreFieldIndex(map, name, lookup);
4979 bool is_in_object = index < 0; 4980 bool is_in_object = index < 0;
4980 int offset = index * kPointerSize; 4981 int offset = index * kPointerSize;
4981 if (index < 0) { 4982 if (index < 0) {
4982 // Negative property indices are in-object properties, indexed 4983 // Negative property indices are in-object properties, indexed
4983 // from the end of the fixed part of the object. 4984 // from the end of the fixed part of the object.
4984 offset += type->instance_size(); 4985 offset += map->instance_size();
4985 } else { 4986 } else {
4986 offset += FixedArray::kHeaderSize; 4987 offset += FixedArray::kHeaderSize;
4987 } 4988 }
4988 HStoreNamedField* instr = 4989 HStoreNamedField* instr =
4989 new(zone()) HStoreNamedField(object, name, value, is_in_object, offset); 4990 new(zone()) HStoreNamedField(object, name, value, is_in_object, offset);
4990 if (lookup->IsTransitionToField(*type)) { 4991 if (lookup->IsTransitionToField(*map)) {
4991 Handle<Map> transition(lookup->GetTransitionMapFromMap(*type)); 4992 Handle<Map> transition(lookup->GetTransitionMapFromMap(*map));
4992 instr->set_transition(transition); 4993 instr->set_transition(transition);
4993 // TODO(fschneider): Record the new map type of the object in the IR to 4994 // TODO(fschneider): Record the new map type of the object in the IR to
4994 // enable elimination of redundant checks after the transition store. 4995 // enable elimination of redundant checks after the transition store.
4995 instr->SetGVNFlag(kChangesMaps); 4996 instr->SetGVNFlag(kChangesMaps);
4996 } 4997 }
4997 return instr; 4998 return instr;
4998 } 4999 }
4999 5000
5000 5001
5001 HInstruction* HGraphBuilder::BuildStoreNamedGeneric(HValue* object, 5002 HInstruction* HGraphBuilder::BuildStoreNamedGeneric(HValue* object,
(...skipping 16 matching lines...) Expand all
5018 Handle<JSObject> holder(JSObject::cast(map->prototype())); 5019 Handle<JSObject> holder(JSObject::cast(map->prototype()));
5019 if (!holder->HasFastProperties()) break; 5020 if (!holder->HasFastProperties()) break;
5020 map = Handle<Map>(holder->map()); 5021 map = Handle<Map>(holder->map());
5021 map->LookupDescriptor(*holder, *name, lookup); 5022 map->LookupDescriptor(*holder, *name, lookup);
5022 if (lookup->IsFound()) return; 5023 if (lookup->IsFound()) return;
5023 } 5024 }
5024 lookup->NotFound(); 5025 lookup->NotFound();
5025 } 5026 }
5026 5027
5027 5028
5028 HInstruction* HGraphBuilder::BuildCallSetter(HValue* obj, 5029 HInstruction* HGraphBuilder::BuildCallSetter(HValue* object,
5029 Handle<String> name,
5030 HValue* value, 5030 HValue* value,
5031 Handle<Map> map, 5031 Handle<Map> map,
5032 Handle<Object> callback, 5032 Handle<AccessorPair> accessors,
5033 Handle<JSObject> holder) { 5033 Handle<JSObject> holder) {
5034 if (!callback->IsAccessorPair()) { 5034 Handle<JSFunction> setter(JSFunction::cast(accessors->setter()));
5035 return BuildStoreNamedGeneric(obj, name, value); 5035 AddCheckConstantFunction(holder, object, map, true);
5036 } 5036 AddInstruction(new(zone()) HPushArgument(object));
5037 Handle<Object> setter(Handle<AccessorPair>::cast(callback)->setter());
5038 Handle<JSFunction> function(Handle<JSFunction>::cast(setter));
5039 AddCheckConstantFunction(holder, obj, map, true);
5040 AddInstruction(new(zone()) HPushArgument(obj));
5041 AddInstruction(new(zone()) HPushArgument(value)); 5037 AddInstruction(new(zone()) HPushArgument(value));
5042 return new(zone()) HCallConstantFunction(function, 2); 5038 return new(zone()) HCallConstantFunction(setter, 2);
5043 } 5039 }
5044 5040
5045 5041
5046 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object, 5042 HInstruction* HGraphBuilder::BuildStoreNamed(HValue* object,
5043 Handle<String> name,
5047 HValue* value, 5044 HValue* value,
5048 Handle<Map> type, 5045 Handle<Map> map) {
5049 Expression* key) {
5050 // If we don't know the monomorphic type, do a generic store. 5046 // If we don't know the monomorphic type, do a generic store.
5051 Handle<String> name = Handle<String>::cast(key->AsLiteral()->handle()); 5047 if (map.is_null()) return BuildStoreNamedGeneric(object, name, value);
5052 if (type.is_null()) return BuildStoreNamedGeneric(object, name, value);
5053 5048
5054 // Handle a store to a known field. 5049 // Handle a store to a known field.
5055 LookupResult lookup(isolate()); 5050 LookupResult lookup(isolate());
5056 if (ComputeLoadStoreField(type, name, &lookup, true)) { 5051 if (ComputeLoadStoreField(map, name, &lookup, true)) {
5057 // true = needs smi and map check. 5052 // true = needs smi and map check.
5058 return BuildStoreNamedField(object, name, value, type, &lookup, true); 5053 return BuildStoreNamedField(object, name, value, map, &lookup, true);
5059 } 5054 }
5060 5055
5061 // Handle a known setter directly in the receiver. 5056 // Handle a known setter directly in the receiver.
5062 type->LookupDescriptor(NULL, *name, &lookup); 5057 map->LookupDescriptor(NULL, *name, &lookup);
5063 if (lookup.IsPropertyCallbacks()) { 5058 if (lookup.IsPropertyCallbacks()) {
5064 Handle<Object> callback(lookup.GetValueFromMap(*type)); 5059 Handle<Object> callback(lookup.GetValueFromMap(*map));
5065 Handle<JSObject> holder; 5060 Handle<JSObject> holder;
5066 return BuildCallSetter(object, name, value, type, callback, holder); 5061 if (!callback->IsAccessorPair()) {
5062 return BuildStoreNamedGeneric(object, name, value);
5063 }
5064 Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(callback);
5065 return BuildCallSetter(object, value, map, accessors, holder);
5067 } 5066 }
5068 5067
5069 // Handle a known setter somewhere in the prototype chain. 5068 // Handle a known setter somewhere in the prototype chain.
5070 LookupInPrototypes(type, name, &lookup); 5069 LookupInPrototypes(map, name, &lookup);
5071 if (lookup.IsPropertyCallbacks()) { 5070 if (lookup.IsPropertyCallbacks()) {
5072 Handle<Object> callback(lookup.GetValue()); 5071 Handle<Object> callback(lookup.GetValue());
5073 Handle<JSObject> holder(lookup.holder()); 5072 Handle<JSObject> holder(lookup.holder());
5074 return BuildCallSetter(object, name, value, type, callback, holder); 5073 if (!callback->IsAccessorPair()) {
5074 return BuildStoreNamedGeneric(object, name, value);
5075 }
5076 Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(callback);
5077 return BuildCallSetter(object, value, map, accessors, holder);
5075 } 5078 }
5076 5079
5077 // No luck, do a generic store. 5080 // No luck, do a generic store.
5078 return BuildStoreNamedGeneric(object, name, value); 5081 return BuildStoreNamedGeneric(object, name, value);
5079 } 5082 }
5080 5083
5081 5084
5082 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr, 5085 void HGraphBuilder::HandlePolymorphicLoadNamedField(Property* expr,
5083 HValue* object, 5086 HValue* object,
5084 SmallMapList* types, 5087 SmallMapList* types,
(...skipping 26 matching lines...) Expand all
5111 } 5114 }
5112 ++count; 5115 ++count;
5113 } 5116 }
5114 } 5117 }
5115 5118
5116 // Use monomorphic load if property lookup results in the same field index 5119 // Use monomorphic load if property lookup results in the same field index
5117 // for all maps. Requires special map check on the set of all handled maps. 5120 // for all maps. Requires special map check on the set of all handled maps.
5118 HInstruction* instr; 5121 HInstruction* instr;
5119 if (count == types->length() && is_monomorphic_field) { 5122 if (count == types->length() && is_monomorphic_field) {
5120 AddInstruction(new(zone()) HCheckMaps(object, types, zone())); 5123 AddInstruction(new(zone()) HCheckMaps(object, types, zone()));
5121 instr = BuildLoadNamedField(object, expr, map, &lookup, false); 5124 instr = BuildLoadNamedField(object, map, &lookup, false);
5122 } else { 5125 } else {
5123 HValue* context = environment()->LookupContext(); 5126 HValue* context = environment()->LookupContext();
5124 instr = new(zone()) HLoadNamedFieldPolymorphic(context, 5127 instr = new(zone()) HLoadNamedFieldPolymorphic(context,
5125 object, 5128 object,
5126 types, 5129 types,
5127 name, 5130 name,
5128 zone()); 5131 zone());
5129 } 5132 }
5130 5133
5131 instr->set_position(expr->position()); 5134 instr->set_position(expr->position());
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 value = Pop(); 5227 value = Pop();
5225 HValue* object = Pop(); 5228 HValue* object = Pop();
5226 5229
5227 Literal* key = prop->key()->AsLiteral(); 5230 Literal* key = prop->key()->AsLiteral();
5228 Handle<String> name = Handle<String>::cast(key->handle()); 5231 Handle<String> name = Handle<String>::cast(key->handle());
5229 ASSERT(!name.is_null()); 5232 ASSERT(!name.is_null());
5230 5233
5231 SmallMapList* types = expr->GetReceiverTypes(); 5234 SmallMapList* types = expr->GetReceiverTypes();
5232 if (expr->IsMonomorphic()) { 5235 if (expr->IsMonomorphic()) {
5233 CHECK_ALIVE(instr = BuildStoreNamed(object, 5236 CHECK_ALIVE(instr = BuildStoreNamed(object,
5237 name,
5234 value, 5238 value,
5235 types->first(), 5239 types->first()));
5236 prop->key()));
5237 5240
5238 } else if (types != NULL && types->length() > 1) { 5241 } else if (types != NULL && types->length() > 1) {
5239 HandlePolymorphicStoreNamedField(expr, object, value, types, name); 5242 HandlePolymorphicStoreNamedField(expr, object, value, types, name);
5240 return; 5243 return;
5241 5244
5242 } else { 5245 } else {
5243 instr = BuildStoreNamedGeneric(object, name, value); 5246 instr = BuildStoreNamedGeneric(object, name, value);
5244 } 5247 }
5245 5248
5246 } else { 5249 } else {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
5384 return Bailout("compound assignment to lookup slot"); 5387 return Bailout("compound assignment to lookup slot");
5385 } 5388 }
5386 return ast_context()->ReturnValue(Pop()); 5389 return ast_context()->ReturnValue(Pop());
5387 5390
5388 } else if (prop != NULL) { 5391 } else if (prop != NULL) {
5389 prop->RecordTypeFeedback(oracle(), zone()); 5392 prop->RecordTypeFeedback(oracle(), zone());
5390 5393
5391 if (prop->key()->IsPropertyName()) { 5394 if (prop->key()->IsPropertyName()) {
5392 // Named property. 5395 // Named property.
5393 CHECK_ALIVE(VisitForValue(prop->obj())); 5396 CHECK_ALIVE(VisitForValue(prop->obj()));
5394 HValue* obj = Top(); 5397 HValue* object = Top();
5395 5398
5399 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
5396 Handle<Map> map; 5400 Handle<Map> map;
5397 HInstruction* load; 5401 HInstruction* load;
5398 if (prop->IsMonomorphic()) { 5402 if (prop->IsMonomorphic()) {
5399 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
5400 map = prop->GetReceiverTypes()->first(); 5403 map = prop->GetReceiverTypes()->first();
5401 load = BuildLoadNamed(obj, prop, map, name); 5404 load = BuildLoadNamed(object, name, prop, map);
5402 } else { 5405 } else {
5403 load = BuildLoadNamedGeneric(obj, prop); 5406 load = BuildLoadNamedGeneric(object, name, prop);
5404 } 5407 }
5405 PushAndAdd(load); 5408 PushAndAdd(load);
5406 if (load->HasObservableSideEffects()) AddSimulate(expr->CompoundLoadId()); 5409 if (load->HasObservableSideEffects()) AddSimulate(expr->CompoundLoadId());
5407 5410
5408 CHECK_ALIVE(VisitForValue(expr->value())); 5411 CHECK_ALIVE(VisitForValue(expr->value()));
5409 HValue* right = Pop(); 5412 HValue* right = Pop();
5410 HValue* left = Pop(); 5413 HValue* left = Pop();
5411 5414
5412 HInstruction* instr = BuildBinaryOperation(operation, left, right); 5415 HInstruction* instr = BuildBinaryOperation(operation, left, right);
5413 PushAndAdd(instr); 5416 PushAndAdd(instr);
5414 if (instr->HasObservableSideEffects()) AddSimulate(operation->id()); 5417 if (instr->HasObservableSideEffects()) AddSimulate(operation->id());
5415 5418
5416 HInstruction* store; 5419 HInstruction* store;
5417 CHECK_ALIVE(store = BuildStoreNamed(obj, instr, map, prop->key())); 5420 CHECK_ALIVE(store = BuildStoreNamed(object, name, instr, map));
5418 AddInstruction(store); 5421 AddInstruction(store);
5419 // Drop the simulated receiver and value. Return the value. 5422 // Drop the simulated receiver and value. Return the value.
5420 Drop(2); 5423 Drop(2);
5421 Push(instr); 5424 Push(instr);
5422 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); 5425 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
5423 return ast_context()->ReturnValue(Pop()); 5426 return ast_context()->ReturnValue(Pop());
5424 5427
5425 } else { 5428 } else {
5426 // Keyed property. 5429 // Keyed property.
5427 CHECK_ALIVE(VisitForValue(prop->obj())); 5430 CHECK_ALIVE(VisitForValue(prop->obj()));
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
5608 HThrow* instr = new(zone()) HThrow(context, value); 5611 HThrow* instr = new(zone()) HThrow(context, value);
5609 instr->set_position(expr->position()); 5612 instr->set_position(expr->position());
5610 AddInstruction(instr); 5613 AddInstruction(instr);
5611 AddSimulate(expr->id()); 5614 AddSimulate(expr->id());
5612 current_block()->FinishExit(new(zone()) HAbnormalExit); 5615 current_block()->FinishExit(new(zone()) HAbnormalExit);
5613 set_current_block(NULL); 5616 set_current_block(NULL);
5614 } 5617 }
5615 5618
5616 5619
5617 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object, 5620 HLoadNamedField* HGraphBuilder::BuildLoadNamedField(HValue* object,
5618 Property* expr, 5621 Handle<Map> map,
5619 Handle<Map> type,
5620 LookupResult* lookup, 5622 LookupResult* lookup,
5621 bool smi_and_map_check) { 5623 bool smi_and_map_check) {
5622 if (smi_and_map_check) { 5624 if (smi_and_map_check) {
5623 AddInstruction(new(zone()) HCheckNonSmi(object)); 5625 AddInstruction(new(zone()) HCheckNonSmi(object));
5624 AddInstruction(HCheckMaps::NewWithTransitions(object, type, zone())); 5626 AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone()));
5625 } 5627 }
5626 5628
5627 int index = lookup->GetLocalFieldIndexFromMap(*type); 5629 int index = lookup->GetLocalFieldIndexFromMap(*map);
5628 if (index < 0) { 5630 if (index < 0) {
5629 // Negative property indices are in-object properties, indexed 5631 // Negative property indices are in-object properties, indexed
5630 // from the end of the fixed part of the object. 5632 // from the end of the fixed part of the object.
5631 int offset = (index * kPointerSize) + type->instance_size(); 5633 int offset = (index * kPointerSize) + map->instance_size();
5632 return new(zone()) HLoadNamedField(object, true, offset); 5634 return new(zone()) HLoadNamedField(object, true, offset);
5633 } else { 5635 } else {
5634 // Non-negative property indices are in the properties array. 5636 // Non-negative property indices are in the properties array.
5635 int offset = (index * kPointerSize) + FixedArray::kHeaderSize; 5637 int offset = (index * kPointerSize) + FixedArray::kHeaderSize;
5636 return new(zone()) HLoadNamedField(object, false, offset); 5638 return new(zone()) HLoadNamedField(object, false, offset);
5637 } 5639 }
5638 } 5640 }
5639 5641
5640 5642
5641 HInstruction* HGraphBuilder::BuildLoadNamedGeneric(HValue* obj, 5643 HInstruction* HGraphBuilder::BuildLoadNamedGeneric(HValue* obj,
5644 Handle<String> name,
5642 Property* expr) { 5645 Property* expr) {
5643 if (expr->IsUninitialized() && !FLAG_always_opt) { 5646 if (expr->IsUninitialized() && !FLAG_always_opt) {
5644 AddInstruction(new(zone()) HSoftDeoptimize); 5647 AddInstruction(new(zone()) HSoftDeoptimize);
5645 current_block()->MarkAsDeoptimizing(); 5648 current_block()->MarkAsDeoptimizing();
5646 } 5649 }
5647 ASSERT(expr->key()->IsPropertyName());
5648 Handle<Object> name = expr->key()->AsLiteral()->handle();
5649 HValue* context = environment()->LookupContext(); 5650 HValue* context = environment()->LookupContext();
5650 return new(zone()) HLoadNamedGeneric(context, obj, name); 5651 return new(zone()) HLoadNamedGeneric(context, obj, name);
5651 } 5652 }
5652 5653
5653 5654
5654 HInstruction* HGraphBuilder::BuildCallGetter(HValue* obj, 5655 HInstruction* HGraphBuilder::BuildCallGetter(HValue* object,
5655 Property* expr,
5656 Handle<Map> map, 5656 Handle<Map> map,
5657 Handle<Object> callback, 5657 Handle<AccessorPair> accessors,
5658 Handle<JSObject> holder) { 5658 Handle<JSObject> holder) {
5659 if (!callback->IsAccessorPair()) return BuildLoadNamedGeneric(obj, expr); 5659 Handle<JSFunction> getter(JSFunction::cast(accessors->getter()));
5660 Handle<Object> getter(Handle<AccessorPair>::cast(callback)->getter()); 5660 AddCheckConstantFunction(holder, object, map, true);
5661 Handle<JSFunction> function(Handle<JSFunction>::cast(getter)); 5661 AddInstruction(new(zone()) HPushArgument(object));
5662 AddCheckConstantFunction(holder, obj, map, true); 5662 return new(zone()) HCallConstantFunction(getter, 1);
5663 AddInstruction(new(zone()) HPushArgument(obj));
5664 return new(zone()) HCallConstantFunction(function, 1);
5665 } 5663 }
5666 5664
5667 5665
5668 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* obj, 5666 HInstruction* HGraphBuilder::BuildLoadNamed(HValue* object,
5667 Handle<String> name,
5669 Property* expr, 5668 Property* expr,
5670 Handle<Map> map, 5669 Handle<Map> map) {
5671 Handle<String> name) {
5672 LookupResult lookup(isolate()); 5670 LookupResult lookup(isolate());
5673 map->LookupDescriptor(NULL, *name, &lookup); 5671 map->LookupDescriptor(NULL, *name, &lookup);
5674 if (lookup.IsField()) { 5672 if (lookup.IsField()) {
5675 return BuildLoadNamedField(obj, 5673 return BuildLoadNamedField(object, map, &lookup, true);
5676 expr,
5677 map,
5678 &lookup,
5679 true);
5680 } else if (lookup.IsConstantFunction()) { 5674 } else if (lookup.IsConstantFunction()) {
5681 AddInstruction(new(zone()) HCheckNonSmi(obj)); 5675 AddInstruction(new(zone()) HCheckNonSmi(object));
5682 AddInstruction(HCheckMaps::NewWithTransitions(obj, map, zone())); 5676 AddInstruction(HCheckMaps::NewWithTransitions(object, map, zone()));
5683 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map)); 5677 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*map));
5684 return new(zone()) HConstant(function, Representation::Tagged()); 5678 return new(zone()) HConstant(function, Representation::Tagged());
5685 } else if (lookup.IsPropertyCallbacks()) { 5679 } else if (lookup.IsPropertyCallbacks()) {
5686 Handle<Object> callback(lookup.GetValueFromMap(*map)); 5680 Handle<Object> callback(lookup.GetValueFromMap(*map));
5687 Handle<JSObject> holder; 5681 Handle<JSObject> holder;
5688 return BuildCallGetter(obj, expr, map, callback, holder); 5682 if (!callback->IsAccessorPair()) {
5683 return BuildLoadNamedGeneric(object, name, expr);
5684 }
5685 Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(callback);
5686 return BuildCallGetter(object, map, accessors, holder);
5689 } else { 5687 } else {
5690 LookupInPrototypes(map, name, &lookup); 5688 LookupInPrototypes(map, name, &lookup);
5691 if (lookup.IsPropertyCallbacks()) { 5689 if (lookup.IsPropertyCallbacks()) {
5692 Handle<Object> callback(lookup.GetValue()); 5690 Handle<Object> callback(lookup.GetValue());
5693 Handle<JSObject> holder(lookup.holder()); 5691 Handle<JSObject> holder(lookup.holder());
5694 return BuildCallGetter(obj, expr, map, callback, holder); 5692 if (!callback->IsAccessorPair()) {
5693 return BuildLoadNamedGeneric(object, name, expr);
5694 }
5695 Handle<AccessorPair> accessors = Handle<AccessorPair>::cast(callback);
5696 return BuildCallGetter(object, map, accessors, holder);
5695 } 5697 }
5696 return BuildLoadNamedGeneric(obj, expr); 5698 return BuildLoadNamedGeneric(object, name, expr);
5697 } 5699 }
5698 } 5700 }
5699 5701
5700 5702
5701 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object, 5703 HInstruction* HGraphBuilder::BuildLoadKeyedGeneric(HValue* object,
5702 HValue* key) { 5704 HValue* key) {
5703 HValue* context = environment()->LookupContext(); 5705 HValue* context = environment()->LookupContext();
5704 return new(zone()) HLoadKeyedGeneric(context, object, key); 5706 return new(zone()) HLoadKeyedGeneric(context, object, key);
5705 } 5707 }
5706 5708
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
6306 HValue* function = Pop(); 6308 HValue* function = Pop();
6307 AddInstruction(new(zone()) HCheckNonSmi(function)); 6309 AddInstruction(new(zone()) HCheckNonSmi(function));
6308 instr = new(zone()) HLoadFunctionPrototype(function); 6310 instr = new(zone()) HLoadFunctionPrototype(function);
6309 6311
6310 } else if (expr->key()->IsPropertyName()) { 6312 } else if (expr->key()->IsPropertyName()) {
6311 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName(); 6313 Handle<String> name = expr->key()->AsLiteral()->AsPropertyName();
6312 SmallMapList* types = expr->GetReceiverTypes(); 6314 SmallMapList* types = expr->GetReceiverTypes();
6313 6315
6314 HValue* obj = Pop(); 6316 HValue* obj = Pop();
6315 if (expr->IsMonomorphic()) { 6317 if (expr->IsMonomorphic()) {
6316 instr = BuildLoadNamed(obj, expr, types->first(), name); 6318 instr = BuildLoadNamed(obj, name, expr, types->first());
6317 } else if (types != NULL && types->length() > 1) { 6319 } else if (types != NULL && types->length() > 1) {
6318 AddInstruction(new(zone()) HCheckNonSmi(obj)); 6320 AddInstruction(new(zone()) HCheckNonSmi(obj));
6319 HandlePolymorphicLoadNamedField(expr, obj, types, name); 6321 HandlePolymorphicLoadNamedField(expr, obj, types, name);
6320 return; 6322 return;
6321 } else { 6323 } else {
6322 instr = BuildLoadNamedGeneric(obj, expr); 6324 instr = BuildLoadNamedGeneric(obj, name, expr);
6323 } 6325 }
6324 6326
6325 } else { 6327 } else {
6326 CHECK_ALIVE(VisitForValue(expr->key())); 6328 CHECK_ALIVE(VisitForValue(expr->key()));
6327 6329
6328 HValue* key = Pop(); 6330 HValue* key = Pop();
6329 HValue* obj = Pop(); 6331 HValue* obj = Pop();
6330 6332
6331 bool has_side_effects = false; 6333 bool has_side_effects = false;
6332 HValue* load = HandleKeyedElementAccess( 6334 HValue* load = HandleKeyedElementAccess(
(...skipping 1458 matching lines...) Expand 10 before | Expand all | Expand 10 after
7791 ASSERT(prop != NULL); 7793 ASSERT(prop != NULL);
7792 prop->RecordTypeFeedback(oracle(), zone()); 7794 prop->RecordTypeFeedback(oracle(), zone());
7793 7795
7794 if (prop->key()->IsPropertyName()) { 7796 if (prop->key()->IsPropertyName()) {
7795 // Named property. 7797 // Named property.
7796 if (returns_original_input) Push(graph_->GetConstantUndefined()); 7798 if (returns_original_input) Push(graph_->GetConstantUndefined());
7797 7799
7798 CHECK_ALIVE(VisitForValue(prop->obj())); 7800 CHECK_ALIVE(VisitForValue(prop->obj()));
7799 HValue* obj = Top(); 7801 HValue* obj = Top();
7800 7802
7803 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
7801 Handle<Map> map; 7804 Handle<Map> map;
7802 HInstruction* load; 7805 HInstruction* load;
7803 if (prop->IsMonomorphic()) { 7806 if (prop->IsMonomorphic()) {
7804 Handle<String> name = prop->key()->AsLiteral()->AsPropertyName();
7805 map = prop->GetReceiverTypes()->first(); 7807 map = prop->GetReceiverTypes()->first();
7806 load = BuildLoadNamed(obj, prop, map, name); 7808 load = BuildLoadNamed(obj, name, prop, map);
7807 } else { 7809 } else {
7808 load = BuildLoadNamedGeneric(obj, prop); 7810 load = BuildLoadNamedGeneric(obj, name, prop);
7809 } 7811 }
7810 PushAndAdd(load); 7812 PushAndAdd(load);
7811 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId()); 7813 if (load->HasObservableSideEffects()) AddSimulate(expr->CountId());
7812 7814
7813 after = BuildIncrement(returns_original_input, expr); 7815 after = BuildIncrement(returns_original_input, expr);
7814 input = Pop(); 7816 input = Pop();
7815 7817
7816 HInstruction* store; 7818 HInstruction* store;
7817 CHECK_ALIVE(store = BuildStoreNamed(obj, after, map, prop->key())); 7819 CHECK_ALIVE(store = BuildStoreNamed(obj, name, after, map));
7818 AddInstruction(store); 7820 AddInstruction(store);
7819 7821
7820 // Overwrite the receiver in the bailout environment with the result 7822 // Overwrite the receiver in the bailout environment with the result
7821 // of the operation, and the placeholder with the original value if 7823 // of the operation, and the placeholder with the original value if
7822 // necessary. 7824 // necessary.
7823 environment()->SetExpressionStackAt(0, after); 7825 environment()->SetExpressionStackAt(0, after);
7824 if (returns_original_input) environment()->SetExpressionStackAt(1, input); 7826 if (returns_original_input) environment()->SetExpressionStackAt(1, input);
7825 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId()); 7827 if (store->HasObservableSideEffects()) AddSimulate(expr->AssignmentId());
7826 7828
7827 } else { 7829 } else {
(...skipping 1755 matching lines...) Expand 10 before | Expand all | Expand 10 after
9583 } 9585 }
9584 } 9586 }
9585 9587
9586 #ifdef DEBUG 9588 #ifdef DEBUG
9587 if (graph_ != NULL) graph_->Verify(false); // No full verify. 9589 if (graph_ != NULL) graph_->Verify(false); // No full verify.
9588 if (allocator_ != NULL) allocator_->Verify(); 9590 if (allocator_ != NULL) allocator_->Verify();
9589 #endif 9591 #endif
9590 } 9592 }
9591 9593
9592 } } // namespace v8::internal 9594 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698