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

Side by Side Diff: src/objects.h

Issue 1180753005: Cleanup typed array setters, the property is guaranteed to be there. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years, 6 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/lookup.cc ('k') | src/objects.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_OBJECTS_H_ 5 #ifndef V8_OBJECTS_H_
6 #define V8_OBJECTS_H_ 6 #define V8_OBJECTS_H_
7 7
8 #include <iosfwd> 8 #include <iosfwd>
9 9
10 #include "src/allocation.h" 10 #include "src/allocation.h"
(...skipping 2415 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 2426
2427 class FixedDoubleArray; 2427 class FixedDoubleArray;
2428 class IncrementalMarking; 2428 class IncrementalMarking;
2429 2429
2430 2430
2431 // FixedArray describes fixed-sized arrays with element type Object*. 2431 // FixedArray describes fixed-sized arrays with element type Object*.
2432 class FixedArray: public FixedArrayBase { 2432 class FixedArray: public FixedArrayBase {
2433 public: 2433 public:
2434 // Setter and getter for elements. 2434 // Setter and getter for elements.
2435 inline Object* get(int index) const; 2435 inline Object* get(int index) const;
2436 static void SetValue(Handle<JSObject> holder, Handle<FixedArray> array, 2436 static void SetValue(Handle<FixedArray> array, uint32_t index,
2437 uint32_t index, Handle<Object> value); 2437 Handle<Object> value);
2438 static inline Handle<Object> get(Handle<FixedArray> array, int index); 2438 static inline Handle<Object> get(Handle<FixedArray> array, int index);
2439 // Setter that uses write barrier. 2439 // Setter that uses write barrier.
2440 inline void set(int index, Object* value); 2440 inline void set(int index, Object* value);
2441 inline bool is_the_hole(int index); 2441 inline bool is_the_hole(int index);
2442 2442
2443 // Setter that doesn't need write barrier. 2443 // Setter that doesn't need write barrier.
2444 inline void set(int index, Smi* value); 2444 inline void set(int index, Smi* value);
2445 // Setter with explicit barrier mode. 2445 // Setter with explicit barrier mode.
2446 inline void set(int index, Object* value, WriteBarrierMode mode); 2446 inline void set(int index, Object* value, WriteBarrierMode mode);
2447 2447
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
2550 2550
2551 2551
2552 // FixedDoubleArray describes fixed-sized arrays with element type double. 2552 // FixedDoubleArray describes fixed-sized arrays with element type double.
2553 class FixedDoubleArray: public FixedArrayBase { 2553 class FixedDoubleArray: public FixedArrayBase {
2554 public: 2554 public:
2555 // Setter and getter for elements. 2555 // Setter and getter for elements.
2556 inline double get_scalar(int index); 2556 inline double get_scalar(int index);
2557 inline uint64_t get_representation(int index); 2557 inline uint64_t get_representation(int index);
2558 static inline Handle<Object> get(Handle<FixedDoubleArray> array, int index); 2558 static inline Handle<Object> get(Handle<FixedDoubleArray> array, int index);
2559 // This accessor has to get a Number as |value|. 2559 // This accessor has to get a Number as |value|.
2560 static void SetValue(Handle<JSObject> holder, Handle<FixedDoubleArray> array, 2560 static void SetValue(Handle<FixedDoubleArray> array, uint32_t index,
2561 uint32_t index, Handle<Object> value); 2561 Handle<Object> value);
2562 inline void set(int index, double value); 2562 inline void set(int index, double value);
2563 inline void set_the_hole(int index); 2563 inline void set_the_hole(int index);
2564 2564
2565 // Checking for the hole. 2565 // Checking for the hole.
2566 inline bool is_the_hole(int index); 2566 inline bool is_the_hole(int index);
2567 2567
2568 // Garbage collection support. 2568 // Garbage collection support.
2569 inline static int SizeFor(int length) { 2569 inline static int SizeFor(int length) {
2570 return kHeaderSize + length * kDoubleSize; 2570 return kHeaderSize + length * kDoubleSize;
2571 } 2571 }
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after
4386 inline uint8_t* external_uint8_clamped_pointer(); 4386 inline uint8_t* external_uint8_clamped_pointer();
4387 4387
4388 // Setter and getter. 4388 // Setter and getter.
4389 inline uint8_t get_scalar(int index); 4389 inline uint8_t get_scalar(int index);
4390 static inline Handle<Object> get(Handle<ExternalUint8ClampedArray> array, 4390 static inline Handle<Object> get(Handle<ExternalUint8ClampedArray> array,
4391 int index); 4391 int index);
4392 inline void set(int index, uint8_t value); 4392 inline void set(int index, uint8_t value);
4393 4393
4394 // This accessor applies the correct conversion from Smi, HeapNumber 4394 // This accessor applies the correct conversion from Smi, HeapNumber
4395 // and undefined and clamps the converted value between 0 and 255. 4395 // and undefined and clamps the converted value between 0 and 255.
4396 static void SetValue(Handle<JSObject> holder, 4396 static void SetValue(Handle<ExternalUint8ClampedArray> array, uint32_t index,
4397 Handle<ExternalUint8ClampedArray> array, uint32_t index,
4398 Handle<Object> value); 4397 Handle<Object> value);
4399 4398
4400 DECLARE_CAST(ExternalUint8ClampedArray) 4399 DECLARE_CAST(ExternalUint8ClampedArray)
4401 4400
4402 // Dispatched behavior. 4401 // Dispatched behavior.
4403 DECLARE_PRINTER(ExternalUint8ClampedArray) 4402 DECLARE_PRINTER(ExternalUint8ClampedArray)
4404 DECLARE_VERIFIER(ExternalUint8ClampedArray) 4403 DECLARE_VERIFIER(ExternalUint8ClampedArray)
4405 4404
4406 private: 4405 private:
4407 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8ClampedArray); 4406 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8ClampedArray);
4408 }; 4407 };
4409 4408
4410 4409
4411 class ExternalInt8Array: public ExternalArray { 4410 class ExternalInt8Array: public ExternalArray {
4412 public: 4411 public:
4413 // Setter and getter. 4412 // Setter and getter.
4414 inline int8_t get_scalar(int index); 4413 inline int8_t get_scalar(int index);
4415 static inline Handle<Object> get(Handle<ExternalInt8Array> array, int index); 4414 static inline Handle<Object> get(Handle<ExternalInt8Array> array, int index);
4416 inline void set(int index, int8_t value); 4415 inline void set(int index, int8_t value);
4417 4416
4418 // This accessor applies the correct conversion from Smi, HeapNumber 4417 // This accessor applies the correct conversion from Smi, HeapNumber
4419 // and undefined. 4418 // and undefined.
4420 static void SetValue(Handle<JSObject> holder, Handle<ExternalInt8Array> array, 4419 static void SetValue(Handle<ExternalInt8Array> array, uint32_t index,
4421 uint32_t index, Handle<Object> value); 4420 Handle<Object> value);
4422 4421
4423 DECLARE_CAST(ExternalInt8Array) 4422 DECLARE_CAST(ExternalInt8Array)
4424 4423
4425 // Dispatched behavior. 4424 // Dispatched behavior.
4426 DECLARE_PRINTER(ExternalInt8Array) 4425 DECLARE_PRINTER(ExternalInt8Array)
4427 DECLARE_VERIFIER(ExternalInt8Array) 4426 DECLARE_VERIFIER(ExternalInt8Array)
4428 4427
4429 private: 4428 private:
4430 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt8Array); 4429 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt8Array);
4431 }; 4430 };
4432 4431
4433 4432
4434 class ExternalUint8Array: public ExternalArray { 4433 class ExternalUint8Array: public ExternalArray {
4435 public: 4434 public:
4436 // Setter and getter. 4435 // Setter and getter.
4437 inline uint8_t get_scalar(int index); 4436 inline uint8_t get_scalar(int index);
4438 static inline Handle<Object> get(Handle<ExternalUint8Array> array, int index); 4437 static inline Handle<Object> get(Handle<ExternalUint8Array> array, int index);
4439 inline void set(int index, uint8_t value); 4438 inline void set(int index, uint8_t value);
4440 4439
4441 // This accessor applies the correct conversion from Smi, HeapNumber 4440 // This accessor applies the correct conversion from Smi, HeapNumber
4442 // and undefined. 4441 // and undefined.
4443 static void SetValue(Handle<JSObject> holder, 4442 static void SetValue(Handle<ExternalUint8Array> array, uint32_t index,
4444 Handle<ExternalUint8Array> array, uint32_t index,
4445 Handle<Object> value); 4443 Handle<Object> value);
4446 4444
4447 DECLARE_CAST(ExternalUint8Array) 4445 DECLARE_CAST(ExternalUint8Array)
4448 4446
4449 // Dispatched behavior. 4447 // Dispatched behavior.
4450 DECLARE_PRINTER(ExternalUint8Array) 4448 DECLARE_PRINTER(ExternalUint8Array)
4451 DECLARE_VERIFIER(ExternalUint8Array) 4449 DECLARE_VERIFIER(ExternalUint8Array)
4452 4450
4453 private: 4451 private:
4454 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8Array); 4452 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint8Array);
4455 }; 4453 };
4456 4454
4457 4455
4458 class ExternalInt16Array: public ExternalArray { 4456 class ExternalInt16Array: public ExternalArray {
4459 public: 4457 public:
4460 // Setter and getter. 4458 // Setter and getter.
4461 inline int16_t get_scalar(int index); 4459 inline int16_t get_scalar(int index);
4462 static inline Handle<Object> get(Handle<ExternalInt16Array> array, int index); 4460 static inline Handle<Object> get(Handle<ExternalInt16Array> array, int index);
4463 inline void set(int index, int16_t value); 4461 inline void set(int index, int16_t value);
4464 4462
4465 // This accessor applies the correct conversion from Smi, HeapNumber 4463 // This accessor applies the correct conversion from Smi, HeapNumber
4466 // and undefined. 4464 // and undefined.
4467 static void SetValue(Handle<JSObject> holder, 4465 static void SetValue(Handle<ExternalInt16Array> array, uint32_t index,
4468 Handle<ExternalInt16Array> array, uint32_t index,
4469 Handle<Object> value); 4466 Handle<Object> value);
4470 4467
4471 DECLARE_CAST(ExternalInt16Array) 4468 DECLARE_CAST(ExternalInt16Array)
4472 4469
4473 // Dispatched behavior. 4470 // Dispatched behavior.
4474 DECLARE_PRINTER(ExternalInt16Array) 4471 DECLARE_PRINTER(ExternalInt16Array)
4475 DECLARE_VERIFIER(ExternalInt16Array) 4472 DECLARE_VERIFIER(ExternalInt16Array)
4476 4473
4477 private: 4474 private:
4478 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt16Array); 4475 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt16Array);
4479 }; 4476 };
4480 4477
4481 4478
4482 class ExternalUint16Array: public ExternalArray { 4479 class ExternalUint16Array: public ExternalArray {
4483 public: 4480 public:
4484 // Setter and getter. 4481 // Setter and getter.
4485 inline uint16_t get_scalar(int index); 4482 inline uint16_t get_scalar(int index);
4486 static inline Handle<Object> get(Handle<ExternalUint16Array> array, 4483 static inline Handle<Object> get(Handle<ExternalUint16Array> array,
4487 int index); 4484 int index);
4488 inline void set(int index, uint16_t value); 4485 inline void set(int index, uint16_t value);
4489 4486
4490 // This accessor applies the correct conversion from Smi, HeapNumber 4487 // This accessor applies the correct conversion from Smi, HeapNumber
4491 // and undefined. 4488 // and undefined.
4492 static void SetValue(Handle<JSObject> holder, 4489 static void SetValue(Handle<ExternalUint16Array> array, uint32_t index,
4493 Handle<ExternalUint16Array> array, uint32_t index,
4494 Handle<Object> value); 4490 Handle<Object> value);
4495 4491
4496 DECLARE_CAST(ExternalUint16Array) 4492 DECLARE_CAST(ExternalUint16Array)
4497 4493
4498 // Dispatched behavior. 4494 // Dispatched behavior.
4499 DECLARE_PRINTER(ExternalUint16Array) 4495 DECLARE_PRINTER(ExternalUint16Array)
4500 DECLARE_VERIFIER(ExternalUint16Array) 4496 DECLARE_VERIFIER(ExternalUint16Array)
4501 4497
4502 private: 4498 private:
4503 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint16Array); 4499 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint16Array);
4504 }; 4500 };
4505 4501
4506 4502
4507 class ExternalInt32Array: public ExternalArray { 4503 class ExternalInt32Array: public ExternalArray {
4508 public: 4504 public:
4509 // Setter and getter. 4505 // Setter and getter.
4510 inline int32_t get_scalar(int index); 4506 inline int32_t get_scalar(int index);
4511 static inline Handle<Object> get(Handle<ExternalInt32Array> array, int index); 4507 static inline Handle<Object> get(Handle<ExternalInt32Array> array, int index);
4512 inline void set(int index, int32_t value); 4508 inline void set(int index, int32_t value);
4513 4509
4514 // This accessor applies the correct conversion from Smi, HeapNumber 4510 // This accessor applies the correct conversion from Smi, HeapNumber
4515 // and undefined. 4511 // and undefined.
4516 static void SetValue(Handle<JSObject> holder, 4512 static void SetValue(Handle<ExternalInt32Array> array, uint32_t index,
4517 Handle<ExternalInt32Array> array, uint32_t index,
4518 Handle<Object> value); 4513 Handle<Object> value);
4519 4514
4520 DECLARE_CAST(ExternalInt32Array) 4515 DECLARE_CAST(ExternalInt32Array)
4521 4516
4522 // Dispatched behavior. 4517 // Dispatched behavior.
4523 DECLARE_PRINTER(ExternalInt32Array) 4518 DECLARE_PRINTER(ExternalInt32Array)
4524 DECLARE_VERIFIER(ExternalInt32Array) 4519 DECLARE_VERIFIER(ExternalInt32Array)
4525 4520
4526 private: 4521 private:
4527 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt32Array); 4522 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalInt32Array);
4528 }; 4523 };
4529 4524
4530 4525
4531 class ExternalUint32Array: public ExternalArray { 4526 class ExternalUint32Array: public ExternalArray {
4532 public: 4527 public:
4533 // Setter and getter. 4528 // Setter and getter.
4534 inline uint32_t get_scalar(int index); 4529 inline uint32_t get_scalar(int index);
4535 static inline Handle<Object> get(Handle<ExternalUint32Array> array, 4530 static inline Handle<Object> get(Handle<ExternalUint32Array> array,
4536 int index); 4531 int index);
4537 inline void set(int index, uint32_t value); 4532 inline void set(int index, uint32_t value);
4538 4533
4539 // This accessor applies the correct conversion from Smi, HeapNumber 4534 // This accessor applies the correct conversion from Smi, HeapNumber
4540 // and undefined. 4535 // and undefined.
4541 static void SetValue(Handle<JSObject> holder, 4536 static void SetValue(Handle<ExternalUint32Array> array, uint32_t index,
4542 Handle<ExternalUint32Array> array, uint32_t index,
4543 Handle<Object> value); 4537 Handle<Object> value);
4544 4538
4545 DECLARE_CAST(ExternalUint32Array) 4539 DECLARE_CAST(ExternalUint32Array)
4546 4540
4547 // Dispatched behavior. 4541 // Dispatched behavior.
4548 DECLARE_PRINTER(ExternalUint32Array) 4542 DECLARE_PRINTER(ExternalUint32Array)
4549 DECLARE_VERIFIER(ExternalUint32Array) 4543 DECLARE_VERIFIER(ExternalUint32Array)
4550 4544
4551 private: 4545 private:
4552 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint32Array); 4546 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUint32Array);
4553 }; 4547 };
4554 4548
4555 4549
4556 class ExternalFloat32Array: public ExternalArray { 4550 class ExternalFloat32Array: public ExternalArray {
4557 public: 4551 public:
4558 // Setter and getter. 4552 // Setter and getter.
4559 inline float get_scalar(int index); 4553 inline float get_scalar(int index);
4560 static inline Handle<Object> get(Handle<ExternalFloat32Array> array, 4554 static inline Handle<Object> get(Handle<ExternalFloat32Array> array,
4561 int index); 4555 int index);
4562 inline void set(int index, float value); 4556 inline void set(int index, float value);
4563 4557
4564 // This accessor applies the correct conversion from Smi, HeapNumber 4558 // This accessor applies the correct conversion from Smi, HeapNumber
4565 // and undefined. 4559 // and undefined.
4566 static void SetValue(Handle<JSObject> holder, 4560 static void SetValue(Handle<ExternalFloat32Array> array, uint32_t index,
4567 Handle<ExternalFloat32Array> array, uint32_t index,
4568 Handle<Object> value); 4561 Handle<Object> value);
4569 4562
4570 DECLARE_CAST(ExternalFloat32Array) 4563 DECLARE_CAST(ExternalFloat32Array)
4571 4564
4572 // Dispatched behavior. 4565 // Dispatched behavior.
4573 DECLARE_PRINTER(ExternalFloat32Array) 4566 DECLARE_PRINTER(ExternalFloat32Array)
4574 DECLARE_VERIFIER(ExternalFloat32Array) 4567 DECLARE_VERIFIER(ExternalFloat32Array)
4575 4568
4576 private: 4569 private:
4577 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat32Array); 4570 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat32Array);
4578 }; 4571 };
4579 4572
4580 4573
4581 class ExternalFloat64Array: public ExternalArray { 4574 class ExternalFloat64Array: public ExternalArray {
4582 public: 4575 public:
4583 // Setter and getter. 4576 // Setter and getter.
4584 inline double get_scalar(int index); 4577 inline double get_scalar(int index);
4585 static inline Handle<Object> get(Handle<ExternalFloat64Array> array, 4578 static inline Handle<Object> get(Handle<ExternalFloat64Array> array,
4586 int index); 4579 int index);
4587 inline void set(int index, double value); 4580 inline void set(int index, double value);
4588 4581
4589 // This accessor applies the correct conversion from Smi, HeapNumber 4582 // This accessor applies the correct conversion from Smi, HeapNumber
4590 // and undefined. 4583 // and undefined.
4591 static void SetValue(Handle<JSObject> holder, 4584 static void SetValue(Handle<ExternalFloat64Array> array, uint32_t index,
4592 Handle<ExternalFloat64Array> array, uint32_t index,
4593 Handle<Object> value); 4585 Handle<Object> value);
4594 4586
4595 DECLARE_CAST(ExternalFloat64Array) 4587 DECLARE_CAST(ExternalFloat64Array)
4596 4588
4597 // Dispatched behavior. 4589 // Dispatched behavior.
4598 DECLARE_PRINTER(ExternalFloat64Array) 4590 DECLARE_PRINTER(ExternalFloat64Array)
4599 DECLARE_VERIFIER(ExternalFloat64Array) 4591 DECLARE_VERIFIER(ExternalFloat64Array)
4600 4592
4601 private: 4593 private:
4602 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array); 4594 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloat64Array);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4651 4643
4652 inline ElementType get_scalar(int index); 4644 inline ElementType get_scalar(int index);
4653 static inline Handle<Object> get(Handle<FixedTypedArray> array, int index); 4645 static inline Handle<Object> get(Handle<FixedTypedArray> array, int index);
4654 inline void set(int index, ElementType value); 4646 inline void set(int index, ElementType value);
4655 4647
4656 static inline ElementType from_int(int value); 4648 static inline ElementType from_int(int value);
4657 static inline ElementType from_double(double value); 4649 static inline ElementType from_double(double value);
4658 4650
4659 // This accessor applies the correct conversion from Smi, HeapNumber 4651 // This accessor applies the correct conversion from Smi, HeapNumber
4660 // and undefined. 4652 // and undefined.
4661 static void SetValue(Handle<JSObject> holder, 4653 static void SetValue(Handle<FixedTypedArray<Traits> > array, uint32_t index,
4662 Handle<FixedTypedArray<Traits> > array, uint32_t index,
4663 Handle<Object> value); 4654 Handle<Object> value);
4664 4655
4665 DECLARE_PRINTER(FixedTypedArray) 4656 DECLARE_PRINTER(FixedTypedArray)
4666 DECLARE_VERIFIER(FixedTypedArray) 4657 DECLARE_VERIFIER(FixedTypedArray)
4667 4658
4668 private: 4659 private:
4669 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray); 4660 DISALLOW_IMPLICIT_CONSTRUCTORS(FixedTypedArray);
4670 }; 4661 };
4671 4662
4672 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \ 4663 #define FIXED_TYPED_ARRAY_TRAITS(Type, type, TYPE, elementType, size) \
(...skipping 6203 matching lines...) Expand 10 before | Expand all | Expand 10 after
10876 } else { 10867 } else {
10877 value &= ~(1 << bit_position); 10868 value &= ~(1 << bit_position);
10878 } 10869 }
10879 return value; 10870 return value;
10880 } 10871 }
10881 }; 10872 };
10882 10873
10883 } } // namespace v8::internal 10874 } } // namespace v8::internal
10884 10875
10885 #endif // V8_OBJECTS_H_ 10876 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/lookup.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698