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

Side by Side Diff: src/objects.cc

Issue 1307943013: [es5] Class of object is "Function" if object has [[Call]]. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address Jakobs comments. Created 5 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/objects.h ('k') | src/x64/lithium-codegen-x64.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 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 "src/objects.h" 5 #include "src/objects.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/accessors.h" 10 #include "src/accessors.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 namespace v8 { 51 namespace v8 {
52 namespace internal { 52 namespace internal {
53 53
54 Handle<HeapType> Object::OptimalType(Isolate* isolate, 54 Handle<HeapType> Object::OptimalType(Isolate* isolate,
55 Representation representation) { 55 Representation representation) {
56 if (representation.IsNone()) return HeapType::None(isolate); 56 if (representation.IsNone()) return HeapType::None(isolate);
57 if (FLAG_track_field_types) { 57 if (FLAG_track_field_types) {
58 if (representation.IsHeapObject() && IsHeapObject()) { 58 if (representation.IsHeapObject() && IsHeapObject()) {
59 // We can track only JavaScript objects with stable maps. 59 // We can track only JavaScript objects with stable maps.
60 Handle<Map> map(HeapObject::cast(this)->map(), isolate); 60 Handle<Map> map(HeapObject::cast(this)->map(), isolate);
61 if (map->is_stable() && 61 if (map->is_stable() && !map->is_callable() &&
62 map->instance_type() >= FIRST_NONCALLABLE_SPEC_OBJECT_TYPE && 62 map->instance_type() >= FIRST_JS_RECEIVER_TYPE &&
63 map->instance_type() <= LAST_NONCALLABLE_SPEC_OBJECT_TYPE) { 63 map->instance_type() <= LAST_JS_RECEIVER_TYPE) {
64 return HeapType::Class(map, isolate); 64 return HeapType::Class(map, isolate);
65 } 65 }
66 } 66 }
67 } 67 }
68 return HeapType::Any(isolate); 68 return HeapType::Any(isolate);
69 } 69 }
70 70
71 71
72 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate, 72 MaybeHandle<JSReceiver> Object::ToObject(Isolate* isolate,
73 Handle<Object> object, 73 Handle<Object> object,
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1643 return hash; 1643 return hash;
1644 } 1644 }
1645 1645
1646 1646
1647 void Simd128Value::CopyBits(void* destination) const { 1647 void Simd128Value::CopyBits(void* destination) const {
1648 memcpy(destination, &READ_BYTE_FIELD(this, kValueOffset), kSimd128Size); 1648 memcpy(destination, &READ_BYTE_FIELD(this, kValueOffset), kSimd128Size);
1649 } 1649 }
1650 1650
1651 1651
1652 String* JSReceiver::class_name() { 1652 String* JSReceiver::class_name() {
1653 if (IsJSFunction() || IsJSFunctionProxy()) { 1653 // According to ES5 section 15 Standard Built-in ECMAScript Objects, the
1654 // [[Class]] of builtin objects is "Function" if a [[Call]] internal
1655 // method is present.
1656 if (IsCallable()) {
1654 return GetHeap()->Function_string(); 1657 return GetHeap()->Function_string();
1655 } 1658 }
1656 Object* maybe_constructor = map()->GetConstructor(); 1659 Object* maybe_constructor = map()->GetConstructor();
1657 if (maybe_constructor->IsJSFunction()) { 1660 if (maybe_constructor->IsJSFunction()) {
1658 JSFunction* constructor = JSFunction::cast(maybe_constructor); 1661 JSFunction* constructor = JSFunction::cast(maybe_constructor);
1659 return String::cast(constructor->shared()->instance_class_name()); 1662 return String::cast(constructor->shared()->instance_class_name());
1660 } 1663 }
1661 // If the constructor is not present, return "Object". 1664 // If the constructor is not present, return "Object".
1662 return GetHeap()->Object_string(); 1665 return GetHeap()->Object_string();
1663 } 1666 }
(...skipping 14504 matching lines...) Expand 10 before | Expand all | Expand 10 after
16168 if (cell->value() != *new_value) { 16171 if (cell->value() != *new_value) {
16169 cell->set_value(*new_value); 16172 cell->set_value(*new_value);
16170 Isolate* isolate = cell->GetIsolate(); 16173 Isolate* isolate = cell->GetIsolate();
16171 cell->dependent_code()->DeoptimizeDependentCodeGroup( 16174 cell->dependent_code()->DeoptimizeDependentCodeGroup(
16172 isolate, DependentCode::kPropertyCellChangedGroup); 16175 isolate, DependentCode::kPropertyCellChangedGroup);
16173 } 16176 }
16174 } 16177 }
16175 16178
16176 } // namespace internal 16179 } // namespace internal
16177 } // namespace v8 16180 } // namespace v8
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/x64/lithium-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698