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

Side by Side Diff: src/hydrogen.cc

Issue 7849017: Mechanical refactor to move ElementsKind type out of JSObject. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: latest changes Created 9 years, 3 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') | src/hydrogen-instructions.h » ('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 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 3897 matching lines...) Expand 10 before | Expand all | Expand 10 after
3908 HValue* key) { 3908 HValue* key) {
3909 HValue* context = environment()->LookupContext(); 3909 HValue* context = environment()->LookupContext();
3910 return new(zone()) HLoadKeyedGeneric(context, object, key); 3910 return new(zone()) HLoadKeyedGeneric(context, object, key);
3911 } 3911 }
3912 3912
3913 3913
3914 HInstruction* HGraphBuilder::BuildExternalArrayElementAccess( 3914 HInstruction* HGraphBuilder::BuildExternalArrayElementAccess(
3915 HValue* external_elements, 3915 HValue* external_elements,
3916 HValue* checked_key, 3916 HValue* checked_key,
3917 HValue* val, 3917 HValue* val,
3918 JSObject::ElementsKind elements_kind, 3918 ElementsKind elements_kind,
3919 bool is_store) { 3919 bool is_store) {
3920 if (is_store) { 3920 if (is_store) {
3921 ASSERT(val != NULL); 3921 ASSERT(val != NULL);
3922 switch (elements_kind) { 3922 switch (elements_kind) {
3923 case JSObject::EXTERNAL_PIXEL_ELEMENTS: { 3923 case EXTERNAL_PIXEL_ELEMENTS: {
3924 HClampToUint8* clamp = new(zone()) HClampToUint8(val); 3924 HClampToUint8* clamp = new(zone()) HClampToUint8(val);
3925 AddInstruction(clamp); 3925 AddInstruction(clamp);
3926 val = clamp; 3926 val = clamp;
3927 break; 3927 break;
3928 } 3928 }
3929 case JSObject::EXTERNAL_BYTE_ELEMENTS: 3929 case EXTERNAL_BYTE_ELEMENTS:
3930 case JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS: 3930 case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3931 case JSObject::EXTERNAL_SHORT_ELEMENTS: 3931 case EXTERNAL_SHORT_ELEMENTS:
3932 case JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS: 3932 case EXTERNAL_UNSIGNED_SHORT_ELEMENTS:
3933 case JSObject::EXTERNAL_INT_ELEMENTS: 3933 case EXTERNAL_INT_ELEMENTS:
3934 case JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS: { 3934 case EXTERNAL_UNSIGNED_INT_ELEMENTS: {
3935 HToInt32* floor_val = new(zone()) HToInt32(val); 3935 HToInt32* floor_val = new(zone()) HToInt32(val);
3936 AddInstruction(floor_val); 3936 AddInstruction(floor_val);
3937 val = floor_val; 3937 val = floor_val;
3938 break; 3938 break;
3939 } 3939 }
3940 case JSObject::EXTERNAL_FLOAT_ELEMENTS: 3940 case EXTERNAL_FLOAT_ELEMENTS:
3941 case JSObject::EXTERNAL_DOUBLE_ELEMENTS: 3941 case EXTERNAL_DOUBLE_ELEMENTS:
3942 break; 3942 break;
3943 case JSObject::FAST_ELEMENTS: 3943 case FAST_ELEMENTS:
3944 case JSObject::FAST_DOUBLE_ELEMENTS: 3944 case FAST_DOUBLE_ELEMENTS:
3945 case JSObject::DICTIONARY_ELEMENTS: 3945 case DICTIONARY_ELEMENTS:
3946 case JSObject::NON_STRICT_ARGUMENTS_ELEMENTS: 3946 case NON_STRICT_ARGUMENTS_ELEMENTS:
3947 UNREACHABLE(); 3947 UNREACHABLE();
3948 break; 3948 break;
3949 } 3949 }
3950 return new(zone()) HStoreKeyedSpecializedArrayElement( 3950 return new(zone()) HStoreKeyedSpecializedArrayElement(
3951 external_elements, checked_key, val, elements_kind); 3951 external_elements, checked_key, val, elements_kind);
3952 } else { 3952 } else {
3953 return new(zone()) HLoadKeyedSpecializedArrayElement( 3953 return new(zone()) HLoadKeyedSpecializedArrayElement(
3954 external_elements, checked_key, elements_kind); 3954 external_elements, checked_key, elements_kind);
3955 } 3955 }
3956 } 3956 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
4020 int ast_id, 4020 int ast_id,
4021 int position, 4021 int position,
4022 bool is_store, 4022 bool is_store,
4023 bool* has_side_effects) { 4023 bool* has_side_effects) {
4024 *has_side_effects = false; 4024 *has_side_effects = false;
4025 AddInstruction(new(zone()) HCheckNonSmi(object)); 4025 AddInstruction(new(zone()) HCheckNonSmi(object));
4026 AddInstruction(HCheckInstanceType::NewIsSpecObject(object)); 4026 AddInstruction(HCheckInstanceType::NewIsSpecObject(object));
4027 SmallMapList* maps = prop->GetReceiverTypes(); 4027 SmallMapList* maps = prop->GetReceiverTypes();
4028 bool todo_external_array = false; 4028 bool todo_external_array = false;
4029 4029
4030 static const int kNumElementTypes = JSObject::kElementsKindCount; 4030 static const int kNumElementTypes = kElementsKindCount;
4031 bool type_todo[kNumElementTypes]; 4031 bool type_todo[kNumElementTypes];
4032 for (int i = 0; i < kNumElementTypes; ++i) { 4032 for (int i = 0; i < kNumElementTypes; ++i) {
4033 type_todo[i] = false; 4033 type_todo[i] = false;
4034 } 4034 }
4035 4035
4036 for (int i = 0; i < maps->length(); ++i) { 4036 for (int i = 0; i < maps->length(); ++i) {
4037 ASSERT(maps->at(i)->IsMap()); 4037 ASSERT(maps->at(i)->IsMap());
4038 type_todo[maps->at(i)->elements_kind()] = true; 4038 type_todo[maps->at(i)->elements_kind()] = true;
4039 if (maps->at(i)->elements_kind() 4039 if (maps->at(i)->elements_kind()
4040 >= JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) { 4040 >= FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND) {
4041 todo_external_array = true; 4041 todo_external_array = true;
4042 } 4042 }
4043 } 4043 }
4044 4044
4045 HBasicBlock* join = graph()->CreateBasicBlock(); 4045 HBasicBlock* join = graph()->CreateBasicBlock();
4046 4046
4047 HInstruction* elements_kind_instr = 4047 HInstruction* elements_kind_instr =
4048 AddInstruction(new(zone()) HElementsKind(object)); 4048 AddInstruction(new(zone()) HElementsKind(object));
4049 HCompareConstantEqAndBranch* elements_kind_branch = NULL; 4049 HCompareConstantEqAndBranch* elements_kind_branch = NULL;
4050 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object)); 4050 HInstruction* elements = AddInstruction(new(zone()) HLoadElements(object));
4051 HLoadExternalArrayPointer* external_elements = NULL; 4051 HLoadExternalArrayPointer* external_elements = NULL;
4052 HInstruction* checked_key = NULL; 4052 HInstruction* checked_key = NULL;
4053 4053
4054 // FAST_ELEMENTS is assumed to be the first case. 4054 // FAST_ELEMENTS is assumed to be the first case.
4055 STATIC_ASSERT(JSObject::FAST_ELEMENTS == 0); 4055 STATIC_ASSERT(FAST_ELEMENTS == 0);
4056 4056
4057 for (JSObject::ElementsKind elements_kind = JSObject::FAST_ELEMENTS; 4057 for (ElementsKind elements_kind = FAST_ELEMENTS;
4058 elements_kind <= JSObject::LAST_ELEMENTS_KIND; 4058 elements_kind <= LAST_ELEMENTS_KIND;
4059 elements_kind = JSObject::ElementsKind(elements_kind + 1)) { 4059 elements_kind = ElementsKind(elements_kind + 1)) {
4060 // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we 4060 // After having handled FAST_ELEMENTS and DICTIONARY_ELEMENTS, we
4061 // need to add some code that's executed for all external array cases. 4061 // need to add some code that's executed for all external array cases.
4062 STATIC_ASSERT(JSObject::LAST_EXTERNAL_ARRAY_ELEMENTS_KIND == 4062 STATIC_ASSERT(LAST_EXTERNAL_ARRAY_ELEMENTS_KIND ==
4063 JSObject::LAST_ELEMENTS_KIND); 4063 LAST_ELEMENTS_KIND);
4064 if (elements_kind == JSObject::FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND 4064 if (elements_kind == FIRST_EXTERNAL_ARRAY_ELEMENTS_KIND
4065 && todo_external_array) { 4065 && todo_external_array) {
4066 HInstruction* length = 4066 HInstruction* length =
4067 AddInstruction(new(zone()) HFixedArrayBaseLength(elements)); 4067 AddInstruction(new(zone()) HFixedArrayBaseLength(elements));
4068 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length)); 4068 checked_key = AddInstruction(new(zone()) HBoundsCheck(key, length));
4069 external_elements = new(zone()) HLoadExternalArrayPointer(elements); 4069 external_elements = new(zone()) HLoadExternalArrayPointer(elements);
4070 AddInstruction(external_elements); 4070 AddInstruction(external_elements);
4071 } 4071 }
4072 if (type_todo[elements_kind]) { 4072 if (type_todo[elements_kind]) {
4073 HBasicBlock* if_true = graph()->CreateBasicBlock(); 4073 HBasicBlock* if_true = graph()->CreateBasicBlock();
4074 HBasicBlock* if_false = graph()->CreateBasicBlock(); 4074 HBasicBlock* if_false = graph()->CreateBasicBlock();
4075 elements_kind_branch = new(zone()) HCompareConstantEqAndBranch( 4075 elements_kind_branch = new(zone()) HCompareConstantEqAndBranch(
4076 elements_kind_instr, elements_kind, Token::EQ_STRICT); 4076 elements_kind_instr, elements_kind, Token::EQ_STRICT);
4077 elements_kind_branch->SetSuccessorAt(0, if_true); 4077 elements_kind_branch->SetSuccessorAt(0, if_true);
4078 elements_kind_branch->SetSuccessorAt(1, if_false); 4078 elements_kind_branch->SetSuccessorAt(1, if_false);
4079 current_block()->Finish(elements_kind_branch); 4079 current_block()->Finish(elements_kind_branch);
4080 4080
4081 set_current_block(if_true); 4081 set_current_block(if_true);
4082 HInstruction* access; 4082 HInstruction* access;
4083 if (elements_kind == JSObject::FAST_ELEMENTS || 4083 if (elements_kind == FAST_ELEMENTS ||
4084 elements_kind == JSObject::FAST_DOUBLE_ELEMENTS) { 4084 elements_kind == FAST_DOUBLE_ELEMENTS) {
4085 bool fast_double_elements = 4085 bool fast_double_elements =
4086 elements_kind == JSObject::FAST_DOUBLE_ELEMENTS; 4086 elements_kind == FAST_DOUBLE_ELEMENTS;
4087 if (is_store && elements_kind == JSObject::FAST_ELEMENTS) { 4087 if (is_store && elements_kind == FAST_ELEMENTS) {
4088 AddInstruction(new(zone()) HCheckMap( 4088 AddInstruction(new(zone()) HCheckMap(
4089 elements, isolate()->factory()->fixed_array_map(), 4089 elements, isolate()->factory()->fixed_array_map(),
4090 elements_kind_branch)); 4090 elements_kind_branch));
4091 } 4091 }
4092 HBasicBlock* if_jsarray = graph()->CreateBasicBlock(); 4092 HBasicBlock* if_jsarray = graph()->CreateBasicBlock();
4093 HBasicBlock* if_fastobject = graph()->CreateBasicBlock(); 4093 HBasicBlock* if_fastobject = graph()->CreateBasicBlock();
4094 HHasInstanceTypeAndBranch* typecheck = 4094 HHasInstanceTypeAndBranch* typecheck =
4095 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE); 4095 new(zone()) HHasInstanceTypeAndBranch(object, JS_ARRAY_TYPE);
4096 typecheck->SetSuccessorAt(0, if_jsarray); 4096 typecheck->SetSuccessorAt(0, if_jsarray);
4097 typecheck->SetSuccessorAt(1, if_fastobject); 4097 typecheck->SetSuccessorAt(1, if_fastobject);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
4142 } 4142 }
4143 } else { 4143 } else {
4144 if (fast_double_elements) { 4144 if (fast_double_elements) {
4145 access = AddInstruction( 4145 access = AddInstruction(
4146 new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key)); 4146 new(zone()) HLoadKeyedFastDoubleElement(elements, checked_key));
4147 } else { 4147 } else {
4148 access = AddInstruction( 4148 access = AddInstruction(
4149 new(zone()) HLoadKeyedFastElement(elements, checked_key)); 4149 new(zone()) HLoadKeyedFastElement(elements, checked_key));
4150 } 4150 }
4151 } 4151 }
4152 } else if (elements_kind == JSObject::DICTIONARY_ELEMENTS) { 4152 } else if (elements_kind == DICTIONARY_ELEMENTS) {
4153 if (is_store) { 4153 if (is_store) {
4154 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val)); 4154 access = AddInstruction(BuildStoreKeyedGeneric(object, key, val));
4155 } else { 4155 } else {
4156 access = AddInstruction(BuildLoadKeyedGeneric(object, key)); 4156 access = AddInstruction(BuildLoadKeyedGeneric(object, key));
4157 } 4157 }
4158 } else { // External array elements. 4158 } else { // External array elements.
4159 access = AddInstruction(BuildExternalArrayElementAccess( 4159 access = AddInstruction(BuildExternalArrayElementAccess(
4160 external_elements, checked_key, val, elements_kind, is_store)); 4160 external_elements, checked_key, val, elements_kind, is_store));
4161 } 4161 }
4162 *has_side_effects |= access->HasSideEffects(); 4162 *has_side_effects |= access->HasSideEffects();
(...skipping 2660 matching lines...) Expand 10 before | Expand all | Expand 10 after
6823 } 6823 }
6824 } 6824 }
6825 6825
6826 #ifdef DEBUG 6826 #ifdef DEBUG
6827 if (graph_ != NULL) graph_->Verify(); 6827 if (graph_ != NULL) graph_->Verify();
6828 if (allocator_ != NULL) allocator_->Verify(); 6828 if (allocator_ != NULL) allocator_->Verify();
6829 #endif 6829 #endif
6830 } 6830 }
6831 6831
6832 } } // namespace v8::internal 6832 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen.h ('k') | src/hydrogen-instructions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698