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

Side by Side Diff: src/objects.cc

Issue 1219943002: Expose SIMD.Float32x4 type to Javascript. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Andreas' review comments Created 5 years, 5 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
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 <iomanip> 5 #include <iomanip>
6 #include <sstream> 6 #include <sstream>
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object); 74 if (object->IsJSReceiver()) return Handle<JSReceiver>::cast(object);
75 Handle<JSFunction> constructor; 75 Handle<JSFunction> constructor;
76 if (object->IsNumber()) { 76 if (object->IsNumber()) {
77 constructor = handle(native_context->number_function(), isolate); 77 constructor = handle(native_context->number_function(), isolate);
78 } else if (object->IsBoolean()) { 78 } else if (object->IsBoolean()) {
79 constructor = handle(native_context->boolean_function(), isolate); 79 constructor = handle(native_context->boolean_function(), isolate);
80 } else if (object->IsString()) { 80 } else if (object->IsString()) {
81 constructor = handle(native_context->string_function(), isolate); 81 constructor = handle(native_context->string_function(), isolate);
82 } else if (object->IsSymbol()) { 82 } else if (object->IsSymbol()) {
83 constructor = handle(native_context->symbol_function(), isolate); 83 constructor = handle(native_context->symbol_function(), isolate);
84 } else if (object->IsFloat32x4()) {
85 constructor = handle(native_context->float32x4_function(), isolate);
84 } else { 86 } else {
85 return MaybeHandle<JSReceiver>(); 87 return MaybeHandle<JSReceiver>();
86 } 88 }
87 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor); 89 Handle<JSObject> result = isolate->factory()->NewJSObject(constructor);
88 Handle<JSValue>::cast(result)->set_value(*object); 90 Handle<JSValue>::cast(result)->set_value(*object);
89 return result; 91 return result;
90 } 92 }
91 93
92 94
93 bool Object::BooleanValue() { 95 bool Object::BooleanValue() {
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 605
604 Map* Object::GetRootMap(Isolate* isolate) { 606 Map* Object::GetRootMap(Isolate* isolate) {
605 DisallowHeapAllocation no_alloc; 607 DisallowHeapAllocation no_alloc;
606 if (IsSmi()) { 608 if (IsSmi()) {
607 Context* context = isolate->context()->native_context(); 609 Context* context = isolate->context()->native_context();
608 return context->number_function()->initial_map(); 610 return context->number_function()->initial_map();
609 } 611 }
610 612
611 HeapObject* heap_object = HeapObject::cast(this); 613 HeapObject* heap_object = HeapObject::cast(this);
612 614
613 // The object is either a number, a string, a boolean, 615 // The object is either a number, a string, a symbol, a boolean, a SIMD value,
614 // a real JS object, or a Harmony proxy. 616 // a real JS object, or a Harmony proxy.
615 if (heap_object->IsJSReceiver()) { 617 if (heap_object->IsJSReceiver()) {
616 return heap_object->map(); 618 return heap_object->map();
617 } 619 }
618 Context* context = isolate->context()->native_context(); 620 Context* context = isolate->context()->native_context();
619 621
620 if (heap_object->IsHeapNumber()) { 622 if (heap_object->IsHeapNumber()) {
621 return context->number_function()->initial_map(); 623 return context->number_function()->initial_map();
622 } 624 }
623 if (heap_object->IsString()) { 625 if (heap_object->IsString()) {
624 return context->string_function()->initial_map(); 626 return context->string_function()->initial_map();
625 } 627 }
626 if (heap_object->IsSymbol()) { 628 if (heap_object->IsSymbol()) {
627 return context->symbol_function()->initial_map(); 629 return context->symbol_function()->initial_map();
628 } 630 }
629 if (heap_object->IsBoolean()) { 631 if (heap_object->IsBoolean()) {
630 return context->boolean_function()->initial_map(); 632 return context->boolean_function()->initial_map();
631 } 633 }
634 if (heap_object->IsFloat32x4()) {
635 return context->float32x4_function()->initial_map();
636 }
632 return isolate->heap()->null_value()->map(); 637 return isolate->heap()->null_value()->map();
633 } 638 }
634 639
635 640
636 Object* Object::GetHash() { 641 Object* Object::GetHash() {
637 Object* hash = GetSimpleHash(); 642 Object* hash = GetSimpleHash();
638 if (hash->IsSmi()) return hash; 643 if (hash->IsSmi()) return hash;
639 644
640 DCHECK(IsJSReceiver()); 645 DCHECK(IsJSReceiver());
641 return JSReceiver::cast(this)->GetIdentityHash(); 646 return JSReceiver::cast(this)->GetIdentityHash();
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 return DoubleToBoolean(value()); 1528 return DoubleToBoolean(value());
1524 } 1529 }
1525 1530
1526 1531
1527 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT 1532 void HeapNumber::HeapNumberPrint(std::ostream& os) { // NOLINT
1528 os << value(); 1533 os << value();
1529 } 1534 }
1530 1535
1531 1536
1532 void Float32x4::Float32x4Print(std::ostream& os) { // NOLINT 1537 void Float32x4::Float32x4Print(std::ostream& os) { // NOLINT
1533 os << get_lane(0) << ", " << get_lane(1) << ", " << get_lane(2) << ", " 1538 char arr[100];
1534 << get_lane(3); 1539 Vector<char> buffer(arr, arraysize(arr));
1540 os << std::string(DoubleToCString(get_lane(0), buffer)) << ", "
1541 << std::string(DoubleToCString(get_lane(1), buffer)) << ", "
1542 << std::string(DoubleToCString(get_lane(2), buffer)) << ", "
1543 << std::string(DoubleToCString(get_lane(3), buffer));
1535 } 1544 }
1536 1545
1537 1546
1538 String* JSReceiver::class_name() { 1547 String* JSReceiver::class_name() {
1539 if (IsJSFunction() || IsJSFunctionProxy()) { 1548 if (IsJSFunction() || IsJSFunctionProxy()) {
1540 return GetHeap()->Function_string(); 1549 return GetHeap()->Function_string();
1541 } 1550 }
1542 Object* maybe_constructor = map()->GetConstructor(); 1551 Object* maybe_constructor = map()->GetConstructor();
1543 if (maybe_constructor->IsJSFunction()) { 1552 if (maybe_constructor->IsJSFunction()) {
1544 JSFunction* constructor = JSFunction::cast(maybe_constructor); 1553 JSFunction* constructor = JSFunction::cast(maybe_constructor);
(...skipping 14632 matching lines...) Expand 10 before | Expand all | Expand 10 after
16177 Handle<Object> new_value) { 16186 Handle<Object> new_value) {
16178 if (cell->value() != *new_value) { 16187 if (cell->value() != *new_value) {
16179 cell->set_value(*new_value); 16188 cell->set_value(*new_value);
16180 Isolate* isolate = cell->GetIsolate(); 16189 Isolate* isolate = cell->GetIsolate();
16181 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16190 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16182 isolate, DependentCode::kPropertyCellChangedGroup); 16191 isolate, DependentCode::kPropertyCellChangedGroup);
16183 } 16192 }
16184 } 16193 }
16185 } // namespace internal 16194 } // namespace internal
16186 } // namespace v8 16195 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | test/mjsunit/harmony/simd.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698