Revert r20652 "Handlify and convert string.length to new API-style accessor."
Reason: test failure with --noenable-sse3. R=dcarney@chromium.org TBR=dcarney@chromium.org Review URL: https://codereview.chromium.org/232933003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20653 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
2564c72036
commit
f4cce54313
@ -37,33 +37,11 @@
|
||||
#include "isolate.h"
|
||||
#include "list-inl.h"
|
||||
#include "property-details.h"
|
||||
#include "api.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
|
||||
static Handle<AccessorInfo> MakeAccessor(Isolate* isolate,
|
||||
Handle<String> name,
|
||||
AccessorGetterCallback getter,
|
||||
AccessorSetterCallback setter,
|
||||
PropertyAttributes attributes) {
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<ExecutableAccessorInfo> info = factory->NewExecutableAccessorInfo();
|
||||
info->set_property_attributes(attributes);
|
||||
info->set_all_can_read(true);
|
||||
info->set_all_can_write(true);
|
||||
info->set_prohibits_overwriting(true);
|
||||
info->set_name(*factory->length_string());
|
||||
info->set_property_attributes(attributes);
|
||||
Handle<Object> get = v8::FromCData(isolate, getter);
|
||||
Handle<Object> set = v8::FromCData(isolate, setter);
|
||||
info->set_getter(*get);
|
||||
if (!(attributes & ReadOnly)) info->set_setter(*set);
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
template <class C>
|
||||
static C* FindInstanceOf(Isolate* isolate, Object* obj) {
|
||||
for (Object* cur = obj; !cur->IsNull(); cur = cur->GetPrototype(isolate)) {
|
||||
@ -256,42 +234,24 @@ const AccessorDescriptor Accessors::ArrayLength = {
|
||||
// Accessors::StringLength
|
||||
//
|
||||
|
||||
void Accessors::StringLengthGetter(
|
||||
v8::Local<v8::String> name,
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(info.GetIsolate());
|
||||
DisallowHeapAllocation no_allocation;
|
||||
HandleScope scope(isolate);
|
||||
Object* value = *Utils::OpenHandle(*info.This());
|
||||
Object* result;
|
||||
if (value->IsJSValue()) value = JSValue::cast(value)->value();
|
||||
if (value->IsString()) {
|
||||
result = Smi::FromInt(String::cast(value)->length());
|
||||
} else {
|
||||
|
||||
MaybeObject* Accessors::StringGetLength(Isolate* isolate,
|
||||
Object* object,
|
||||
void*) {
|
||||
Object* value = object;
|
||||
if (object->IsJSValue()) value = JSValue::cast(object)->value();
|
||||
if (value->IsString()) return Smi::FromInt(String::cast(value)->length());
|
||||
// If object is not a string we return 0 to be compatible with WebKit.
|
||||
// Note: Firefox returns the length of ToString(object).
|
||||
result = Smi::FromInt(0);
|
||||
}
|
||||
info.GetReturnValue().Set(Utils::ToLocal(Handle<Object>(result, isolate)));
|
||||
return Smi::FromInt(0);
|
||||
}
|
||||
|
||||
|
||||
void Accessors::StringLengthSetter(
|
||||
v8::Local<v8::String> name,
|
||||
v8::Local<v8::Value> value,
|
||||
const v8::PropertyCallbackInfo<void>& info) {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
Handle<AccessorInfo> Accessors::StringLengthInfo(
|
||||
Isolate* isolate, PropertyAttributes attributes) {
|
||||
return MakeAccessor(isolate,
|
||||
isolate->factory()->length_string(),
|
||||
&StringLengthGetter,
|
||||
&StringLengthSetter,
|
||||
attributes);
|
||||
}
|
||||
const AccessorDescriptor Accessors::StringLength = {
|
||||
StringGetLength,
|
||||
IllegalSetter,
|
||||
0
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
|
@ -43,6 +43,7 @@ namespace internal {
|
||||
V(FunctionArguments) \
|
||||
V(FunctionCaller) \
|
||||
V(ArrayLength) \
|
||||
V(StringLength) \
|
||||
V(ScriptSource) \
|
||||
V(ScriptName) \
|
||||
V(ScriptId) \
|
||||
@ -56,9 +57,6 @@ namespace internal {
|
||||
V(ScriptEvalFromScriptPosition) \
|
||||
V(ScriptEvalFromFunctionName)
|
||||
|
||||
#define ACCESSOR_INFO_LIST(V) \
|
||||
V(StringLength) \
|
||||
|
||||
// Accessors contains all predefined proxy accessors.
|
||||
|
||||
class Accessors : public AllStatic {
|
||||
@ -69,30 +67,11 @@ class Accessors : public AllStatic {
|
||||
ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
|
||||
#undef ACCESSOR_DESCRIPTOR_DECLARATION
|
||||
|
||||
#define ACCESSOR_INFO_DECLARATION(name) \
|
||||
static void name##Getter( \
|
||||
v8::Local<v8::String> name, \
|
||||
const v8::PropertyCallbackInfo<v8::Value>& info); \
|
||||
static void name##Setter( \
|
||||
v8::Local<v8::String> name, \
|
||||
v8::Local<v8::Value> value, \
|
||||
const v8::PropertyCallbackInfo<void>& info); \
|
||||
static Handle<AccessorInfo> name##Info( \
|
||||
Isolate* isolate, \
|
||||
PropertyAttributes attributes);
|
||||
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
||||
#undef ACCESSOR_INFO_DECLARATION
|
||||
|
||||
enum DescriptorId {
|
||||
#define ACCESSOR_DESCRIPTOR_DECLARATION(name) \
|
||||
k##name,
|
||||
ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
|
||||
#undef ACCESSOR_DESCRIPTOR_DECLARATION
|
||||
#define ACCESSOR_INFO_DECLARATION(name) \
|
||||
k##name##Getter, \
|
||||
k##name##Setter,
|
||||
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
||||
#undef ACCESSOR_INFO_DECLARATION
|
||||
descriptorCount
|
||||
};
|
||||
|
||||
@ -113,6 +92,7 @@ class Accessors : public AllStatic {
|
||||
Handle<String> name,
|
||||
int* object_offset);
|
||||
|
||||
|
||||
private:
|
||||
// Accessor functions only used through the descriptor.
|
||||
static MaybeObject* FunctionSetPrototype(Isolate* isolate,
|
||||
|
@ -920,10 +920,10 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
factory->NewDescriptorArray(0, 1));
|
||||
DescriptorArray::WhitenessWitness witness(*string_descriptors);
|
||||
|
||||
Handle<Foreign> string_length(
|
||||
factory->NewForeign(&Accessors::StringLength));
|
||||
PropertyAttributes attribs = static_cast<PropertyAttributes>(
|
||||
DONT_ENUM | DONT_DELETE | READ_ONLY);
|
||||
Handle<AccessorInfo> string_length(
|
||||
Accessors::StringLengthInfo(isolate, attribs));
|
||||
string_map->set_instance_descriptors(*string_descriptors);
|
||||
|
||||
{ // Add length.
|
||||
|
@ -276,21 +276,10 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
|
||||
ACCESSOR, \
|
||||
Accessors::k##name, \
|
||||
"Accessors::" #name);
|
||||
|
||||
ACCESSOR_DESCRIPTOR_LIST(ACCESSOR_DESCRIPTOR_DECLARATION)
|
||||
#undef ACCESSOR_DESCRIPTOR_DECLARATION
|
||||
|
||||
#define ACCESSOR_INFO_DECLARATION(name) \
|
||||
Add(FUNCTION_ADDR(&Accessors::name##Getter), \
|
||||
ACCESSOR, \
|
||||
Accessors::k##name##Getter, \
|
||||
"Accessors::" #name "Getter"); \
|
||||
Add(FUNCTION_ADDR(&Accessors::name##Setter), \
|
||||
ACCESSOR, \
|
||||
Accessors::k##name##Setter, \
|
||||
"Accessors::" #name "Setter");
|
||||
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
|
||||
#undef ACCESSOR_INFO_DECLARATION
|
||||
|
||||
StubCache* stub_cache = isolate->stub_cache();
|
||||
|
||||
// Stub cache tables
|
||||
|
Loading…
Reference in New Issue
Block a user