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

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

Issue 71163006: Merge bleeding_edge r17376:17693. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Fix all.gyp Created 7 years, 1 month 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/checks.cc ('k') | src/code-stubs.cc » ('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 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 25 matching lines...) Expand all
36 36
37 namespace v8 { 37 namespace v8 {
38 namespace internal { 38 namespace internal {
39 39
40 // List of code stubs used on all platforms. 40 // List of code stubs used on all platforms.
41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \ 41 #define CODE_STUB_LIST_ALL_PLATFORMS(V) \
42 V(CallFunction) \ 42 V(CallFunction) \
43 V(CallConstruct) \ 43 V(CallConstruct) \
44 V(BinaryOp) \ 44 V(BinaryOp) \
45 V(StringAdd) \ 45 V(StringAdd) \
46 V(NewStringAdd) \
46 V(SubString) \ 47 V(SubString) \
47 V(StringCompare) \ 48 V(StringCompare) \
48 V(Compare) \ 49 V(Compare) \
49 V(CompareIC) \ 50 V(CompareIC) \
50 V(CompareNilIC) \ 51 V(CompareNilIC) \
51 V(MathPow) \ 52 V(MathPow) \
52 V(StringLength) \ 53 V(StringLength) \
53 V(FunctionPrototype) \ 54 V(FunctionPrototype) \
54 V(StoreArrayLength) \ 55 V(StoreArrayLength) \
55 V(RecordWrite) \ 56 V(RecordWrite) \
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 270
270 virtual Code::Kind GetCodeKind() const { return Code::STUB; } 271 virtual Code::Kind GetCodeKind() const { return Code::STUB; }
271 272
272 protected: 273 protected:
273 // Generates the assembler code for the stub. 274 // Generates the assembler code for the stub.
274 virtual void Generate(MacroAssembler* masm) = 0; 275 virtual void Generate(MacroAssembler* masm) = 0;
275 }; 276 };
276 277
277 278
278 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE }; 279 enum StubFunctionMode { NOT_JS_FUNCTION_STUB_MODE, JS_FUNCTION_STUB_MODE };
279 280 enum HandlerArgumentsMode { DONT_PASS_ARGUMENTS, PASS_ARGUMENTS };
280 281
281 struct CodeStubInterfaceDescriptor { 282 struct CodeStubInterfaceDescriptor {
282 CodeStubInterfaceDescriptor(); 283 CodeStubInterfaceDescriptor();
283 int register_param_count_; 284 int register_param_count_;
285
284 Register stack_parameter_count_; 286 Register stack_parameter_count_;
285 // if hint_stack_parameter_count_ > 0, the code stub can optimize the 287 // if hint_stack_parameter_count_ > 0, the code stub can optimize the
286 // return sequence. Default value is -1, which means it is ignored. 288 // return sequence. Default value is -1, which means it is ignored.
287 int hint_stack_parameter_count_; 289 int hint_stack_parameter_count_;
288 StubFunctionMode function_mode_; 290 StubFunctionMode function_mode_;
289 Register* register_params_; 291 Register* register_params_;
292
290 Address deoptimization_handler_; 293 Address deoptimization_handler_;
294 HandlerArgumentsMode handler_arguments_mode_;
291 295
292 int environment_length() const { 296 int environment_length() const {
293 if (stack_parameter_count_.is_valid()) {
294 return register_param_count_ + 1;
295 }
296 return register_param_count_; 297 return register_param_count_;
297 } 298 }
298 299
299 bool initialized() const { return register_param_count_ >= 0; } 300 bool initialized() const { return register_param_count_ >= 0; }
300 301
301 void SetMissHandler(ExternalReference handler) { 302 void SetMissHandler(ExternalReference handler) {
302 miss_handler_ = handler; 303 miss_handler_ = handler;
303 has_miss_handler_ = true; 304 has_miss_handler_ = true;
305 // Our miss handler infrastructure doesn't currently support
306 // variable stack parameter counts.
307 ASSERT(!stack_parameter_count_.is_valid());
304 } 308 }
305 309
306 ExternalReference miss_handler() { 310 ExternalReference miss_handler() {
307 ASSERT(has_miss_handler_); 311 ASSERT(has_miss_handler_);
308 return miss_handler_; 312 return miss_handler_;
309 } 313 }
310 314
311 bool has_miss_handler() { 315 bool has_miss_handler() {
312 return has_miss_handler_; 316 return has_miss_handler_;
313 } 317 }
314 318
319 Register GetParameterRegister(int index) {
320 return register_params_[index];
321 }
322
323 bool IsParameterCountRegister(int index) {
324 return GetParameterRegister(index).is(stack_parameter_count_);
325 }
326
327 int GetHandlerParameterCount() {
328 int params = environment_length();
329 if (handler_arguments_mode_ == PASS_ARGUMENTS) {
330 params += 1;
331 }
332 return params;
333 }
334
315 private: 335 private:
316 ExternalReference miss_handler_; 336 ExternalReference miss_handler_;
317 bool has_miss_handler_; 337 bool has_miss_handler_;
318 }; 338 };
319 339
320 // A helper to make up for the fact that type Register is not fully
321 // defined outside of the platform directories
322 #define DESCRIPTOR_GET_PARAMETER_REGISTER(descriptor, index) \
323 ((index) == (descriptor)->register_param_count_) \
324 ? (descriptor)->stack_parameter_count_ \
325 : (descriptor)->register_params_[(index)]
326
327 340
328 class HydrogenCodeStub : public CodeStub { 341 class HydrogenCodeStub : public CodeStub {
329 public: 342 public:
330 enum InitializationState { 343 enum InitializationState {
331 UNINITIALIZED, 344 UNINITIALIZED,
332 INITIALIZED 345 INITIALIZED
333 }; 346 };
334 347
335 explicit HydrogenCodeStub(InitializationState state = INITIALIZED) { 348 explicit HydrogenCodeStub(InitializationState state = INITIALIZED) {
336 is_uninitialized_ = (state == UNINITIALIZED); 349 is_uninitialized_ = (state == UNINITIALIZED);
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 559
547 void Generate(MacroAssembler* masm); 560 void Generate(MacroAssembler* masm);
548 561
549 private: 562 private:
550 int slots_; 563 int slots_;
551 564
552 Major MajorKey() { return FastNewBlockContext; } 565 Major MajorKey() { return FastNewBlockContext; }
553 int MinorKey() { return slots_; } 566 int MinorKey() { return slots_; }
554 }; 567 };
555 568
556 class StoreGlobalStub : public HydrogenCodeStub {
557 public:
558 StoreGlobalStub(StrictModeFlag strict_mode, bool is_constant) {
559 bit_field_ = StrictModeBits::encode(strict_mode) |
560 IsConstantBits::encode(is_constant);
561 }
562
563 virtual Handle<Code> GenerateCode(Isolate* isolate);
564
565 virtual void InitializeInterfaceDescriptor(
566 Isolate* isolate,
567 CodeStubInterfaceDescriptor* descriptor);
568
569 virtual Code::Kind GetCodeKind() const { return Code::STORE_IC; }
570 virtual InlineCacheState GetICState() { return MONOMORPHIC; }
571 virtual Code::ExtraICState GetExtraICState() { return bit_field_; }
572
573 bool is_constant() {
574 return IsConstantBits::decode(bit_field_);
575 }
576 void set_is_constant(bool value) {
577 bit_field_ = IsConstantBits::update(bit_field_, value);
578 }
579
580 Representation representation() {
581 return Representation::FromKind(RepresentationBits::decode(bit_field_));
582 }
583 void set_representation(Representation r) {
584 bit_field_ = RepresentationBits::update(bit_field_, r.kind());
585 }
586
587 private:
588 virtual int NotMissMinorKey() { return GetExtraICState(); }
589 Major MajorKey() { return StoreGlobal; }
590
591 class StrictModeBits: public BitField<StrictModeFlag, 0, 1> {};
592 class IsConstantBits: public BitField<bool, 1, 1> {};
593 class RepresentationBits: public BitField<Representation::Kind, 2, 8> {};
594
595 int bit_field_;
596
597 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub);
598 };
599
600
601 class FastCloneShallowArrayStub : public HydrogenCodeStub { 569 class FastCloneShallowArrayStub : public HydrogenCodeStub {
602 public: 570 public:
603 // Maximum length of copied elements array. 571 // Maximum length of copied elements array.
604 static const int kMaximumClonedLength = 8; 572 static const int kMaximumClonedLength = 8;
605 enum Mode { 573 enum Mode {
606 CLONE_ELEMENTS, 574 CLONE_ELEMENTS,
607 CLONE_DOUBLE_ELEMENTS, 575 CLONE_DOUBLE_ELEMENTS,
608 COPY_ON_WRITE_ELEMENTS, 576 COPY_ON_WRITE_ELEMENTS,
609 CLONE_ANY_ELEMENTS, 577 CLONE_ANY_ELEMENTS,
610 LAST_CLONE_MODE = CLONE_ANY_ELEMENTS 578 LAST_CLONE_MODE = CLONE_ANY_ELEMENTS
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 virtual CodeStub::Major MajorKey() { return StoreArrayLength; } 860 virtual CodeStub::Major MajorKey() { return StoreArrayLength; }
893 }; 861 };
894 862
895 863
896 class HICStub: public HydrogenCodeStub { 864 class HICStub: public HydrogenCodeStub {
897 public: 865 public:
898 virtual Code::Kind GetCodeKind() const { return kind(); } 866 virtual Code::Kind GetCodeKind() const { return kind(); }
899 virtual InlineCacheState GetICState() { return MONOMORPHIC; } 867 virtual InlineCacheState GetICState() { return MONOMORPHIC; }
900 868
901 protected: 869 protected:
902 HICStub() { }
903 class KindBits: public BitField<Code::Kind, 0, 4> {}; 870 class KindBits: public BitField<Code::Kind, 0, 4> {};
904 virtual Code::Kind kind() const = 0; 871 virtual Code::Kind kind() const = 0;
905 }; 872 };
906 873
907 874
908 class HandlerStub: public HICStub { 875 class HandlerStub: public HICStub {
909 public: 876 public:
910 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; } 877 virtual Code::Kind GetCodeKind() const { return Code::HANDLER; }
911 virtual int GetStubFlags() { return kind(); } 878 virtual int GetStubFlags() { return kind(); }
912
913 protected:
914 HandlerStub() : HICStub() { }
915 }; 879 };
916 880
917 881
918 class LoadFieldStub: public HandlerStub { 882 class LoadFieldStub: public HandlerStub {
919 public: 883 public:
920 LoadFieldStub(bool inobject, int index, Representation representation) 884 LoadFieldStub(bool inobject, int index, Representation representation) {
921 : HandlerStub() {
922 Initialize(Code::LOAD_IC, inobject, index, representation); 885 Initialize(Code::LOAD_IC, inobject, index, representation);
923 } 886 }
924 887
925 virtual Handle<Code> GenerateCode(Isolate* isolate); 888 virtual Handle<Code> GenerateCode(Isolate* isolate);
926 889
927 virtual void InitializeInterfaceDescriptor( 890 virtual void InitializeInterfaceDescriptor(
928 Isolate* isolate, 891 Isolate* isolate,
929 CodeStubInterfaceDescriptor* descriptor); 892 CodeStubInterfaceDescriptor* descriptor);
930 893
931 Representation representation() { 894 Representation representation() {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 class InobjectBits: public BitField<bool, 4, 1> {}; 936 class InobjectBits: public BitField<bool, 4, 1> {};
974 class IndexBits: public BitField<int, 5, 11> {}; 937 class IndexBits: public BitField<int, 5, 11> {};
975 class UnboxedDoubleBits: public BitField<bool, 16, 1> {}; 938 class UnboxedDoubleBits: public BitField<bool, 16, 1> {};
976 virtual CodeStub::Major MajorKey() { return LoadField; } 939 virtual CodeStub::Major MajorKey() { return LoadField; }
977 virtual int NotMissMinorKey() { return bit_field_; } 940 virtual int NotMissMinorKey() { return bit_field_; }
978 941
979 int bit_field_; 942 int bit_field_;
980 }; 943 };
981 944
982 945
946 class StoreGlobalStub : public HandlerStub {
947 public:
948 StoreGlobalStub(StrictModeFlag strict_mode, bool is_constant) {
949 bit_field_ = StrictModeBits::encode(strict_mode) |
950 IsConstantBits::encode(is_constant);
951 }
952
953 Handle<Code> GetCodeCopyFromTemplate(Isolate* isolate,
954 Map* receiver_map,
955 PropertyCell* cell) {
956 Handle<Code> code = CodeStub::GetCodeCopyFromTemplate(isolate);
957 // Replace the placeholder cell and global object map with the actual global
958 // cell and receiver map.
959 Map* cell_map = isolate->heap()->global_property_cell_map();
960 code->ReplaceNthObject(1, cell_map, cell);
961 code->ReplaceNthObject(1, isolate->heap()->meta_map(), receiver_map);
962 return code;
963 }
964
965 virtual Code::Kind kind() const { return Code::STORE_IC; }
966
967 virtual Handle<Code> GenerateCode(Isolate* isolate);
968
969 virtual void InitializeInterfaceDescriptor(
970 Isolate* isolate,
971 CodeStubInterfaceDescriptor* descriptor);
972
973 virtual Code::ExtraICState GetExtraICState() { return bit_field_; }
974
975 bool is_constant() {
976 return IsConstantBits::decode(bit_field_);
977 }
978 void set_is_constant(bool value) {
979 bit_field_ = IsConstantBits::update(bit_field_, value);
980 }
981
982 Representation representation() {
983 return Representation::FromKind(RepresentationBits::decode(bit_field_));
984 }
985 void set_representation(Representation r) {
986 bit_field_ = RepresentationBits::update(bit_field_, r.kind());
987 }
988
989 private:
990 virtual int NotMissMinorKey() { return GetExtraICState(); }
991 Major MajorKey() { return StoreGlobal; }
992
993 class StrictModeBits: public BitField<StrictModeFlag, 0, 1> {};
994 class IsConstantBits: public BitField<bool, 1, 1> {};
995 class RepresentationBits: public BitField<Representation::Kind, 2, 8> {};
996
997 int bit_field_;
998
999 DISALLOW_COPY_AND_ASSIGN(StoreGlobalStub);
1000 };
1001
1002
983 class KeyedLoadFieldStub: public LoadFieldStub { 1003 class KeyedLoadFieldStub: public LoadFieldStub {
984 public: 1004 public:
985 KeyedLoadFieldStub(bool inobject, int index, Representation representation) 1005 KeyedLoadFieldStub(bool inobject, int index, Representation representation)
986 : LoadFieldStub() { 1006 : LoadFieldStub() {
987 Initialize(Code::KEYED_LOAD_IC, inobject, index, representation); 1007 Initialize(Code::KEYED_LOAD_IC, inobject, index, representation);
988 } 1008 }
989 1009
990 virtual void InitializeInterfaceDescriptor( 1010 virtual void InitializeInterfaceDescriptor(
991 Isolate* isolate, 1011 Isolate* isolate,
992 CodeStubInterfaceDescriptor* descriptor); 1012 CodeStubInterfaceDescriptor* descriptor);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 Token::Value op_; 1185 Token::Value op_;
1166 OverwriteMode mode_; 1186 OverwriteMode mode_;
1167 1187
1168 Maybe<int> fixed_right_arg_; 1188 Maybe<int> fixed_right_arg_;
1169 State left_state_; 1189 State left_state_;
1170 State right_state_; 1190 State right_state_;
1171 State result_state_; 1191 State result_state_;
1172 }; 1192 };
1173 1193
1174 1194
1195 // TODO(bmeurer): Rename to StringAddStub once we dropped the old StringAddStub.
1196 class NewStringAddStub V8_FINAL : public HydrogenCodeStub {
1197 public:
1198 NewStringAddStub(StringAddFlags flags, PretenureFlag pretenure_flag)
1199 : bit_field_(StringAddFlagsBits::encode(flags) |
1200 PretenureFlagBits::encode(pretenure_flag)) {}
1201
1202 StringAddFlags flags() const {
1203 return StringAddFlagsBits::decode(bit_field_);
1204 }
1205
1206 PretenureFlag pretenure_flag() const {
1207 return PretenureFlagBits::decode(bit_field_);
1208 }
1209
1210 virtual Handle<Code> GenerateCode(Isolate* isolate) V8_OVERRIDE;
1211
1212 virtual void InitializeInterfaceDescriptor(
1213 Isolate* isolate,
1214 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
1215
1216 static void InstallDescriptors(Isolate* isolate);
1217
1218 // Parameters accessed via CodeStubGraphBuilder::GetParameter()
1219 static const int kLeft = 0;
1220 static const int kRight = 1;
1221
1222 private:
1223 class StringAddFlagsBits: public BitField<StringAddFlags, 0, 2> {};
1224 class PretenureFlagBits: public BitField<PretenureFlag, 2, 1> {};
1225 uint32_t bit_field_;
1226
1227 virtual Major MajorKey() V8_OVERRIDE { return NewStringAdd; }
1228 virtual int NotMissMinorKey() V8_OVERRIDE { return bit_field_; }
1229
1230 virtual void PrintBaseName(StringStream* stream) V8_OVERRIDE;
1231
1232 DISALLOW_COPY_AND_ASSIGN(NewStringAddStub);
1233 };
1234
1235
1175 class ICCompareStub: public PlatformCodeStub { 1236 class ICCompareStub: public PlatformCodeStub {
1176 public: 1237 public:
1177 ICCompareStub(Token::Value op, 1238 ICCompareStub(Token::Value op,
1178 CompareIC::State left, 1239 CompareIC::State left,
1179 CompareIC::State right, 1240 CompareIC::State right,
1180 CompareIC::State handler) 1241 CompareIC::State handler)
1181 : op_(op), 1242 : op_(op),
1182 left_(left), 1243 left_(left),
1183 right_(right), 1244 right_(right),
1184 state_(handler) { 1245 state_(handler) {
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 int MinorKey() { return 0; } 2418 int MinorKey() { return 0; }
2358 2419
2359 void Generate(MacroAssembler* masm); 2420 void Generate(MacroAssembler* masm);
2360 2421
2361 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub); 2422 DISALLOW_COPY_AND_ASSIGN(ProfileEntryHookStub);
2362 }; 2423 };
2363 2424
2364 } } // namespace v8::internal 2425 } } // namespace v8::internal
2365 2426
2366 #endif // V8_CODE_STUBS_H_ 2427 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « src/checks.cc ('k') | src/code-stubs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698