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

Side by Side Diff: src/code-stubs.cc

Issue 2319243002: [stubs] Fixing loads/stores from arrays by int32 offsets/indices. Step 3. (Closed)
Patch Set: Fixing redness Created 4 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
« no previous file with comments | « src/code-stub-assembler.cc ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/code-stubs.h" 5 #include "src/code-stubs.h"
6 6
7 #include <sstream> 7 #include <sstream>
8 8
9 #include "src/ast/ast.h" 9 #include "src/ast/ast.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 2583 matching lines...) Expand 10 before | Expand all | Expand 10 after
2594 typedef CodeStubAssembler::Variable Variable; 2594 typedef CodeStubAssembler::Variable Variable;
2595 2595
2596 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler), 2596 Label if_number(assembler, Label::kDeferred), if_notsmi(assembler),
2597 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred), 2597 if_jsreceiver(assembler), if_noconstructor(assembler, Label::kDeferred),
2598 if_wrapjsvalue(assembler); 2598 if_wrapjsvalue(assembler);
2599 2599
2600 Node* object = assembler->Parameter(Descriptor::kArgument); 2600 Node* object = assembler->Parameter(Descriptor::kArgument);
2601 Node* context = assembler->Parameter(Descriptor::kContext); 2601 Node* context = assembler->Parameter(Descriptor::kContext);
2602 2602
2603 Variable constructor_function_index_var(assembler, 2603 Variable constructor_function_index_var(assembler,
2604 MachineRepresentation::kWord32); 2604 MachineType::PointerRepresentation());
2605 2605
2606 assembler->Branch(assembler->WordIsSmi(object), &if_number, &if_notsmi); 2606 assembler->Branch(assembler->WordIsSmi(object), &if_number, &if_notsmi);
2607 2607
2608 assembler->Bind(&if_notsmi); 2608 assembler->Bind(&if_notsmi);
2609 Node* map = assembler->LoadMap(object); 2609 Node* map = assembler->LoadMap(object);
2610 2610
2611 assembler->GotoIf( 2611 assembler->GotoIf(
2612 assembler->WordEqual(map, assembler->HeapNumberMapConstant()), 2612 assembler->WordEqual(map, assembler->HeapNumberMapConstant()),
2613 &if_number); 2613 &if_number);
2614 2614
2615 Node* instance_type = assembler->LoadMapInstanceType(map); 2615 Node* instance_type = assembler->LoadMapInstanceType(map);
2616 assembler->GotoIf( 2616 assembler->GotoIf(
2617 assembler->Int32GreaterThanOrEqual( 2617 assembler->Int32GreaterThanOrEqual(
2618 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)), 2618 instance_type, assembler->Int32Constant(FIRST_JS_RECEIVER_TYPE)),
2619 &if_jsreceiver); 2619 &if_jsreceiver);
2620 2620
2621 Node* constructor_function_index = assembler->LoadObjectField( 2621 Node* constructor_function_index =
2622 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, 2622 assembler->LoadMapConstructorFunctionIndex(map);
2623 MachineType::Uint8()); 2623 assembler->GotoIf(assembler->WordEqual(constructor_function_index,
2624 assembler->GotoIf( 2624 assembler->IntPtrConstant(
2625 assembler->Word32Equal( 2625 Map::kNoConstructorFunctionIndex)),
2626 constructor_function_index, 2626 &if_noconstructor);
2627 assembler->Int32Constant(Map::kNoConstructorFunctionIndex)),
2628 &if_noconstructor);
2629 constructor_function_index_var.Bind(constructor_function_index); 2627 constructor_function_index_var.Bind(constructor_function_index);
2630 assembler->Goto(&if_wrapjsvalue); 2628 assembler->Goto(&if_wrapjsvalue);
2631 2629
2632 assembler->Bind(&if_number); 2630 assembler->Bind(&if_number);
2633 constructor_function_index_var.Bind( 2631 constructor_function_index_var.Bind(
2634 assembler->Int32Constant(Context::NUMBER_FUNCTION_INDEX)); 2632 assembler->IntPtrConstant(Context::NUMBER_FUNCTION_INDEX));
2635 assembler->Goto(&if_wrapjsvalue); 2633 assembler->Goto(&if_wrapjsvalue);
2636 2634
2637 assembler->Bind(&if_wrapjsvalue); 2635 assembler->Bind(&if_wrapjsvalue);
2638 Node* native_context = assembler->LoadNativeContext(context); 2636 Node* native_context = assembler->LoadNativeContext(context);
2639 Node* constructor = assembler->LoadFixedArrayElement( 2637 Node* constructor = assembler->LoadFixedArrayElement(
2640 native_context, constructor_function_index_var.value()); 2638 native_context, constructor_function_index_var.value(), 0,
2639 CodeStubAssembler::INTPTR_PARAMETERS);
2641 Node* initial_map = assembler->LoadObjectField( 2640 Node* initial_map = assembler->LoadObjectField(
2642 constructor, JSFunction::kPrototypeOrInitialMapOffset); 2641 constructor, JSFunction::kPrototypeOrInitialMapOffset);
2643 Node* js_value = assembler->Allocate(JSValue::kSize); 2642 Node* js_value = assembler->Allocate(JSValue::kSize);
2644 assembler->StoreMapNoWriteBarrier(js_value, initial_map); 2643 assembler->StoreMapNoWriteBarrier(js_value, initial_map);
2645 assembler->StoreObjectFieldRoot(js_value, JSValue::kPropertiesOffset, 2644 assembler->StoreObjectFieldRoot(js_value, JSValue::kPropertiesOffset,
2646 Heap::kEmptyFixedArrayRootIndex); 2645 Heap::kEmptyFixedArrayRootIndex);
2647 assembler->StoreObjectFieldRoot(js_value, JSObject::kElementsOffset, 2646 assembler->StoreObjectFieldRoot(js_value, JSObject::kElementsOffset,
2648 Heap::kEmptyFixedArrayRootIndex); 2647 Heap::kEmptyFixedArrayRootIndex);
2649 assembler->StoreObjectField(js_value, JSValue::kValueOffset, object); 2648 assembler->StoreObjectField(js_value, JSValue::kValueOffset, object);
2650 assembler->Return(js_value); 2649 assembler->Return(js_value);
(...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after
4420 4419
4421 void LoadApiGetterStub::GenerateAssembly(CodeStubAssembler* assembler) const { 4420 void LoadApiGetterStub::GenerateAssembly(CodeStubAssembler* assembler) const {
4422 typedef compiler::Node Node; 4421 typedef compiler::Node Node;
4423 Node* context = assembler->Parameter(Descriptor::kContext); 4422 Node* context = assembler->Parameter(Descriptor::kContext);
4424 Node* receiver = assembler->Parameter(Descriptor::kReceiver); 4423 Node* receiver = assembler->Parameter(Descriptor::kReceiver);
4425 // For now we only support receiver_is_holder. 4424 // For now we only support receiver_is_holder.
4426 DCHECK(receiver_is_holder()); 4425 DCHECK(receiver_is_holder());
4427 Node* holder = receiver; 4426 Node* holder = receiver;
4428 Node* map = assembler->LoadMap(receiver); 4427 Node* map = assembler->LoadMap(receiver);
4429 Node* descriptors = assembler->LoadMapDescriptors(map); 4428 Node* descriptors = assembler->LoadMapDescriptors(map);
4430 Node* offset = 4429 Node* value_index =
4431 assembler->Int32Constant(DescriptorArray::ToValueIndex(index())); 4430 assembler->IntPtrConstant(DescriptorArray::ToValueIndex(index()));
4432 Node* callback = assembler->LoadFixedArrayElement(descriptors, offset); 4431 Node* callback = assembler->LoadFixedArrayElement(
4432 descriptors, value_index, 0, CodeStubAssembler::INTPTR_PARAMETERS);
4433 assembler->TailCallStub(CodeFactory::ApiGetter(isolate()), context, receiver, 4433 assembler->TailCallStub(CodeFactory::ApiGetter(isolate()), context, receiver,
4434 holder, callback); 4434 holder, callback);
4435 } 4435 }
4436 4436
4437 // static 4437 // static
4438 compiler::Node* LessThanStub::Generate(CodeStubAssembler* assembler, 4438 compiler::Node* LessThanStub::Generate(CodeStubAssembler* assembler,
4439 compiler::Node* lhs, compiler::Node* rhs, 4439 compiler::Node* lhs, compiler::Node* rhs,
4440 compiler::Node* context) { 4440 compiler::Node* context) {
4441 return GenerateAbstractRelationalComparison(assembler, kLessThan, lhs, rhs, 4441 return GenerateAbstractRelationalComparison(assembler, kLessThan, lhs, rhs,
4442 context); 4442 context);
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
5186 Node* compiler_hints = assembler->LoadObjectField( 5186 Node* compiler_hints = assembler->LoadObjectField(
5187 shared_info, SharedFunctionInfo::kCompilerHintsOffset, 5187 shared_info, SharedFunctionInfo::kCompilerHintsOffset,
5188 MachineType::Uint32()); 5188 MachineType::Uint32());
5189 Node* is_strict = assembler->Word32And( 5189 Node* is_strict = assembler->Word32And(
5190 compiler_hints, 5190 compiler_hints,
5191 assembler->Int32Constant(1 << SharedFunctionInfo::kStrictModeBit)); 5191 assembler->Int32Constant(1 << SharedFunctionInfo::kStrictModeBit));
5192 5192
5193 Label if_normal(assembler), if_generator(assembler), if_async(assembler), 5193 Label if_normal(assembler), if_generator(assembler), if_async(assembler),
5194 if_class_constructor(assembler), if_function_without_prototype(assembler), 5194 if_class_constructor(assembler), if_function_without_prototype(assembler),
5195 load_map(assembler); 5195 load_map(assembler);
5196 Variable map_index(assembler, MachineRepresentation::kTagged); 5196 Variable map_index(assembler, MachineType::PointerRepresentation());
5197 5197
5198 Node* is_not_normal = assembler->Word32And( 5198 Node* is_not_normal = assembler->Word32And(
5199 compiler_hints, 5199 compiler_hints,
5200 assembler->Int32Constant(SharedFunctionInfo::kFunctionKindMaskBits)); 5200 assembler->Int32Constant(SharedFunctionInfo::kFunctionKindMaskBits));
5201 assembler->GotoUnless(is_not_normal, &if_normal); 5201 assembler->GotoUnless(is_not_normal, &if_normal);
5202 5202
5203 Node* is_generator = assembler->Word32And( 5203 Node* is_generator = assembler->Word32And(
5204 compiler_hints, 5204 compiler_hints,
5205 assembler->Int32Constant(1 << SharedFunctionInfo::kIsGeneratorBit)); 5205 assembler->Int32Constant(1 << SharedFunctionInfo::kIsGeneratorBit));
5206 assembler->GotoIf(is_generator, &if_generator); 5206 assembler->GotoIf(is_generator, &if_generator);
(...skipping 14 matching lines...) Expand all
5221 compiler_hints, assembler->Int32Constant( 5221 compiler_hints, assembler->Int32Constant(
5222 SharedFunctionInfo::kAccessorFunctionBits | 5222 SharedFunctionInfo::kAccessorFunctionBits |
5223 (1 << SharedFunctionInfo::kIsArrowBit) | 5223 (1 << SharedFunctionInfo::kIsArrowBit) |
5224 (1 << SharedFunctionInfo::kIsConciseMethodBit)))); 5224 (1 << SharedFunctionInfo::kIsConciseMethodBit))));
5225 } 5225 }
5226 assembler->Goto(&if_function_without_prototype); 5226 assembler->Goto(&if_function_without_prototype);
5227 5227
5228 assembler->Bind(&if_normal); 5228 assembler->Bind(&if_normal);
5229 { 5229 {
5230 map_index.Bind(assembler->Select( 5230 map_index.Bind(assembler->Select(
5231 is_strict, assembler->Int32Constant(Context::STRICT_FUNCTION_MAP_INDEX), 5231 is_strict,
5232 assembler->Int32Constant(Context::SLOPPY_FUNCTION_MAP_INDEX))); 5232 assembler->IntPtrConstant(Context::STRICT_FUNCTION_MAP_INDEX),
5233 assembler->IntPtrConstant(Context::SLOPPY_FUNCTION_MAP_INDEX)));
5233 assembler->Goto(&load_map); 5234 assembler->Goto(&load_map);
5234 } 5235 }
5235 5236
5236 assembler->Bind(&if_generator); 5237 assembler->Bind(&if_generator);
5237 { 5238 {
5238 map_index.Bind(assembler->Select( 5239 map_index.Bind(assembler->Select(
5239 is_strict, 5240 is_strict,
5240 assembler->Int32Constant(Context::STRICT_GENERATOR_FUNCTION_MAP_INDEX), 5241 assembler->IntPtrConstant(Context::STRICT_GENERATOR_FUNCTION_MAP_INDEX),
5241 assembler->Int32Constant( 5242 assembler->IntPtrConstant(
5242 Context::SLOPPY_GENERATOR_FUNCTION_MAP_INDEX))); 5243 Context::SLOPPY_GENERATOR_FUNCTION_MAP_INDEX)));
5243 assembler->Goto(&load_map); 5244 assembler->Goto(&load_map);
5244 } 5245 }
5245 5246
5246 assembler->Bind(&if_async); 5247 assembler->Bind(&if_async);
5247 { 5248 {
5248 map_index.Bind(assembler->Select( 5249 map_index.Bind(assembler->Select(
5249 is_strict, 5250 is_strict,
5250 assembler->Int32Constant(Context::STRICT_ASYNC_FUNCTION_MAP_INDEX), 5251 assembler->IntPtrConstant(Context::STRICT_ASYNC_FUNCTION_MAP_INDEX),
5251 assembler->Int32Constant(Context::SLOPPY_ASYNC_FUNCTION_MAP_INDEX))); 5252 assembler->IntPtrConstant(Context::SLOPPY_ASYNC_FUNCTION_MAP_INDEX)));
5252 assembler->Goto(&load_map); 5253 assembler->Goto(&load_map);
5253 } 5254 }
5254 5255
5255 assembler->Bind(&if_class_constructor); 5256 assembler->Bind(&if_class_constructor);
5256 { 5257 {
5257 map_index.Bind( 5258 map_index.Bind(
5258 assembler->Int32Constant(Context::STRICT_FUNCTION_MAP_INDEX)); 5259 assembler->IntPtrConstant(Context::STRICT_FUNCTION_MAP_INDEX));
5259 assembler->Goto(&load_map); 5260 assembler->Goto(&load_map);
5260 } 5261 }
5261 5262
5262 assembler->Bind(&if_function_without_prototype); 5263 assembler->Bind(&if_function_without_prototype);
5263 { 5264 {
5264 map_index.Bind(assembler->Int32Constant( 5265 map_index.Bind(assembler->IntPtrConstant(
5265 Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX)); 5266 Context::STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX));
5266 assembler->Goto(&load_map); 5267 assembler->Goto(&load_map);
5267 } 5268 }
5268 5269
5269 assembler->Bind(&load_map); 5270 assembler->Bind(&load_map);
5270 5271
5271 // Get the function map in the current native context and set that 5272 // Get the function map in the current native context and set that
5272 // as the map of the allocated object. 5273 // as the map of the allocated object.
5273 Node* native_context = assembler->LoadNativeContext(context); 5274 Node* native_context = assembler->LoadNativeContext(context);
5274 Node* map_slot_value = 5275 Node* map_slot_value =
5275 assembler->LoadFixedArrayElement(native_context, map_index.value()); 5276 assembler->LoadFixedArrayElement(native_context, map_index.value(), 0,
5277 CodeStubAssembler::INTPTR_PARAMETERS);
5276 assembler->StoreMapNoWriteBarrier(result, map_slot_value); 5278 assembler->StoreMapNoWriteBarrier(result, map_slot_value);
5277 5279
5278 // Initialize the rest of the function. 5280 // Initialize the rest of the function.
5279 Node* empty_fixed_array = 5281 Node* empty_fixed_array =
5280 assembler->HeapConstant(factory->empty_fixed_array()); 5282 assembler->HeapConstant(factory->empty_fixed_array());
5281 Node* empty_literals_array = 5283 Node* empty_literals_array =
5282 assembler->HeapConstant(factory->empty_literals_array()); 5284 assembler->HeapConstant(factory->empty_literals_array());
5283 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset, 5285 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kPropertiesOffset,
5284 empty_fixed_array); 5286 empty_fixed_array);
5285 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset, 5287 assembler->StoreObjectFieldNoWriteBarrier(result, JSObject::kElementsOffset,
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after
5848 5850
5849 if (type == MachineType::Pointer()) { 5851 if (type == MachineType::Pointer()) {
5850 return Representation::External(); 5852 return Representation::External();
5851 } 5853 }
5852 5854
5853 return Representation::Tagged(); 5855 return Representation::Tagged();
5854 } 5856 }
5855 5857
5856 } // namespace internal 5858 } // namespace internal
5857 } // namespace v8 5859 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698