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

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

Issue 450273002: Extend ToBooleanStub to be able to return oddballs. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | src/code-stubs-hydrogen.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 // 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 #ifndef V8_CODE_STUBS_H_ 5 #ifndef V8_CODE_STUBS_H_
6 #define V8_CODE_STUBS_H_ 6 #define V8_CODE_STUBS_H_
7 7
8 #include "src/allocation.h" 8 #include "src/allocation.h"
9 #include "src/assembler.h" 9 #include "src/assembler.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 2297 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 BOOLEAN, 2308 BOOLEAN,
2309 NULL_TYPE, 2309 NULL_TYPE,
2310 SMI, 2310 SMI,
2311 SPEC_OBJECT, 2311 SPEC_OBJECT,
2312 STRING, 2312 STRING,
2313 SYMBOL, 2313 SYMBOL,
2314 HEAP_NUMBER, 2314 HEAP_NUMBER,
2315 NUMBER_OF_TYPES 2315 NUMBER_OF_TYPES
2316 }; 2316 };
2317 2317
2318 enum ResultMode {
2319 RESULT_AS_SMI, // For Smi(1) on truthy value, Smi(0) otherwise.
2320 RESULT_AS_ODDBALL, // For {true} on truthy value, {false} otherwise.
2321 RESULT_AS_INVERSE_ODDBALL // For {false} on truthy value, {true} otherwise.
2322 };
2323
2318 // At most 8 different types can be distinguished, because the Code object 2324 // At most 8 different types can be distinguished, because the Code object
2319 // only has room for a single byte to hold a set of these types. :-P 2325 // only has room for a single byte to hold a set of these types. :-P
2320 STATIC_ASSERT(NUMBER_OF_TYPES <= 8); 2326 STATIC_ASSERT(NUMBER_OF_TYPES <= 8);
2321 2327
2322 class Types : public EnumSet<Type, byte> { 2328 class Types : public EnumSet<Type, byte> {
2323 public: 2329 public:
2324 Types() : EnumSet<Type, byte>(0) {} 2330 Types() : EnumSet<Type, byte>(0) {}
2325 explicit Types(byte bits) : EnumSet<Type, byte>(bits) {} 2331 explicit Types(byte bits) : EnumSet<Type, byte>(bits) {}
2326 2332
2327 byte ToByte() const { return ToIntegral(); } 2333 byte ToByte() const { return ToIntegral(); }
2328 bool UpdateStatus(Handle<Object> object); 2334 bool UpdateStatus(Handle<Object> object);
2329 bool NeedsMap() const; 2335 bool NeedsMap() const;
2330 bool CanBeUndetectable() const; 2336 bool CanBeUndetectable() const;
2331 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); } 2337 bool IsGeneric() const { return ToIntegral() == Generic().ToIntegral(); }
2332 2338
2333 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); } 2339 static Types Generic() { return Types((1 << NUMBER_OF_TYPES) - 1); }
2334 }; 2340 };
2335 2341
2336 ToBooleanStub(Isolate* isolate, Types types = Types()) 2342 ToBooleanStub(Isolate* isolate, ResultMode mode, Types types = Types())
2337 : HydrogenCodeStub(isolate), types_(types) { } 2343 : HydrogenCodeStub(isolate), types_(types), mode_(mode) {}
2338 ToBooleanStub(Isolate* isolate, ExtraICState state) 2344 ToBooleanStub(Isolate* isolate, ExtraICState state)
2339 : HydrogenCodeStub(isolate), types_(static_cast<byte>(state)) { } 2345 : HydrogenCodeStub(isolate),
2346 types_(static_cast<byte>(state)),
2347 mode_(RESULT_AS_SMI) {}
2340 2348
2341 bool UpdateStatus(Handle<Object> object); 2349 bool UpdateStatus(Handle<Object> object);
2342 Types GetTypes() { return types_; } 2350 Types GetTypes() { return types_; }
2351 ResultMode GetMode() { return mode_; }
2343 2352
2344 virtual Handle<Code> GenerateCode() V8_OVERRIDE; 2353 virtual Handle<Code> GenerateCode() V8_OVERRIDE;
2345 virtual void InitializeInterfaceDescriptor( 2354 virtual void InitializeInterfaceDescriptor(
2346 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE; 2355 CodeStubInterfaceDescriptor* descriptor) V8_OVERRIDE;
2347 2356
2348 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; } 2357 virtual Code::Kind GetCodeKind() const { return Code::TO_BOOLEAN_IC; }
2349 virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT 2358 virtual void PrintState(OStream& os) const V8_OVERRIDE; // NOLINT
2350 2359
2351 virtual bool SometimesSetsUpAFrame() { return false; } 2360 virtual bool SometimesSetsUpAFrame() { return false; }
2352 2361
2353 static void InstallDescriptors(Isolate* isolate) { 2362 static void InstallDescriptors(Isolate* isolate) {
2354 ToBooleanStub stub(isolate); 2363 ToBooleanStub stub(isolate, RESULT_AS_SMI);
2355 stub.InitializeInterfaceDescriptor( 2364 stub.InitializeInterfaceDescriptor(
2356 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean)); 2365 isolate->code_stub_interface_descriptor(CodeStub::ToBoolean));
2357 } 2366 }
2358 2367
2359 static Handle<Code> GetUninitialized(Isolate* isolate) { 2368 static Handle<Code> GetUninitialized(Isolate* isolate) {
2360 return ToBooleanStub(isolate, UNINITIALIZED).GetCode(); 2369 return ToBooleanStub(isolate, UNINITIALIZED).GetCode();
2361 } 2370 }
2362 2371
2363 virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); } 2372 virtual ExtraICState GetExtraICState() const { return types_.ToIntegral(); }
2364 2373
2365 virtual InlineCacheState GetICState() const { 2374 virtual InlineCacheState GetICState() const {
2366 if (types_.IsEmpty()) { 2375 if (types_.IsEmpty()) {
2367 return ::v8::internal::UNINITIALIZED; 2376 return ::v8::internal::UNINITIALIZED;
2368 } else { 2377 } else {
2369 return MONOMORPHIC; 2378 return MONOMORPHIC;
2370 } 2379 }
2371 } 2380 }
2372 2381
2373 private: 2382 private:
2383 class TypesBits : public BitField<byte, 0, NUMBER_OF_TYPES> {};
2384 class ResultModeBits : public BitField<ResultMode, NUMBER_OF_TYPES, 2> {};
2385
2374 Major MajorKey() const { return ToBoolean; } 2386 Major MajorKey() const { return ToBoolean; }
2375 int NotMissMinorKey() const { return GetExtraICState(); } 2387 int NotMissMinorKey() const {
2388 return TypesBits::encode(types_.ToByte()) | ResultModeBits::encode(mode_);
2389 }
2376 2390
2377 ToBooleanStub(Isolate* isolate, InitializationState init_state) : 2391 ToBooleanStub(Isolate* isolate, InitializationState init_state)
2378 HydrogenCodeStub(isolate, init_state) {} 2392 : HydrogenCodeStub(isolate, init_state), mode_(RESULT_AS_SMI) {}
2379 2393
2380 Types types_; 2394 Types types_;
2395 ResultMode mode_;
2381 }; 2396 };
2382 2397
2383 2398
2384 OStream& operator<<(OStream& os, const ToBooleanStub::Types& t); 2399 OStream& operator<<(OStream& os, const ToBooleanStub::Types& t);
2385 2400
2386 2401
2387 class ElementsTransitionAndStoreStub : public HydrogenCodeStub { 2402 class ElementsTransitionAndStoreStub : public HydrogenCodeStub {
2388 public: 2403 public:
2389 ElementsTransitionAndStoreStub(Isolate* isolate, 2404 ElementsTransitionAndStoreStub(Isolate* isolate,
2390 ElementsKind from_kind, 2405 ElementsKind from_kind,
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2510 2525
2511 2526
2512 class CallDescriptors { 2527 class CallDescriptors {
2513 public: 2528 public:
2514 static void InitializeForIsolate(Isolate* isolate); 2529 static void InitializeForIsolate(Isolate* isolate);
2515 }; 2530 };
2516 2531
2517 } } // namespace v8::internal 2532 } } // namespace v8::internal
2518 2533
2519 #endif // V8_CODE_STUBS_H_ 2534 #endif // V8_CODE_STUBS_H_
OLDNEW
« no previous file with comments | « no previous file | src/code-stubs-hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698