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

Side by Side Diff: src/objects.cc

Issue 234623004: Revert "Handlify GetDeclaredAccessorProperty." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 8 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 | no next file » | 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 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 203
204 204
205 template<typename To> 205 template<typename To>
206 static inline To* CheckedCast(void *from) { 206 static inline To* CheckedCast(void *from) {
207 uintptr_t temp = reinterpret_cast<uintptr_t>(from); 207 uintptr_t temp = reinterpret_cast<uintptr_t>(from);
208 ASSERT(temp % sizeof(To) == 0); 208 ASSERT(temp % sizeof(To) == 0);
209 return reinterpret_cast<To*>(temp); 209 return reinterpret_cast<To*>(temp);
210 } 210 }
211 211
212 212
213 static Handle<Object> PerformCompare(const BitmaskCompareDescriptor& descriptor, 213 static MaybeObject* PerformCompare(const BitmaskCompareDescriptor& descriptor,
214 char* ptr, 214 char* ptr,
215 Isolate* isolate) { 215 Heap* heap) {
216 uint32_t bitmask = descriptor.bitmask; 216 uint32_t bitmask = descriptor.bitmask;
217 uint32_t compare_value = descriptor.compare_value; 217 uint32_t compare_value = descriptor.compare_value;
218 uint32_t value; 218 uint32_t value;
219 switch (descriptor.size) { 219 switch (descriptor.size) {
220 case 1: 220 case 1:
221 value = static_cast<uint32_t>(*CheckedCast<uint8_t>(ptr)); 221 value = static_cast<uint32_t>(*CheckedCast<uint8_t>(ptr));
222 compare_value &= 0xff; 222 compare_value &= 0xff;
223 bitmask &= 0xff; 223 bitmask &= 0xff;
224 break; 224 break;
225 case 2: 225 case 2:
226 value = static_cast<uint32_t>(*CheckedCast<uint16_t>(ptr)); 226 value = static_cast<uint32_t>(*CheckedCast<uint16_t>(ptr));
227 compare_value &= 0xffff; 227 compare_value &= 0xffff;
228 bitmask &= 0xffff; 228 bitmask &= 0xffff;
229 break; 229 break;
230 case 4: 230 case 4:
231 value = *CheckedCast<uint32_t>(ptr); 231 value = *CheckedCast<uint32_t>(ptr);
232 break; 232 break;
233 default: 233 default:
234 UNREACHABLE(); 234 UNREACHABLE();
235 return isolate->factory()->undefined_value(); 235 return NULL;
236 } 236 }
237 return isolate->factory()->ToBoolean( 237 return heap->ToBoolean((bitmask & value) == (bitmask & compare_value));
238 (bitmask & value) == (bitmask & compare_value));
239 } 238 }
240 239
241 240
242 static Handle<Object> PerformCompare(const PointerCompareDescriptor& descriptor, 241 static MaybeObject* PerformCompare(const PointerCompareDescriptor& descriptor,
243 char* ptr, 242 char* ptr,
244 Isolate* isolate) { 243 Heap* heap) {
245 uintptr_t compare_value = 244 uintptr_t compare_value =
246 reinterpret_cast<uintptr_t>(descriptor.compare_value); 245 reinterpret_cast<uintptr_t>(descriptor.compare_value);
247 uintptr_t value = *CheckedCast<uintptr_t>(ptr); 246 uintptr_t value = *CheckedCast<uintptr_t>(ptr);
248 return isolate->factory()->ToBoolean(compare_value == value); 247 return heap->ToBoolean(compare_value == value);
249 } 248 }
250 249
251 250
252 static Handle<Object> GetPrimitiveValue( 251 static MaybeObject* GetPrimitiveValue(
253 const PrimitiveValueDescriptor& descriptor, 252 const PrimitiveValueDescriptor& descriptor,
254 char* ptr, 253 char* ptr,
255 Isolate* isolate) { 254 Heap* heap) {
256 int32_t int32_value = 0; 255 int32_t int32_value = 0;
257 switch (descriptor.data_type) { 256 switch (descriptor.data_type) {
258 case kDescriptorInt8Type: 257 case kDescriptorInt8Type:
259 int32_value = *CheckedCast<int8_t>(ptr); 258 int32_value = *CheckedCast<int8_t>(ptr);
260 break; 259 break;
261 case kDescriptorUint8Type: 260 case kDescriptorUint8Type:
262 int32_value = *CheckedCast<uint8_t>(ptr); 261 int32_value = *CheckedCast<uint8_t>(ptr);
263 break; 262 break;
264 case kDescriptorInt16Type: 263 case kDescriptorInt16Type:
265 int32_value = *CheckedCast<int16_t>(ptr); 264 int32_value = *CheckedCast<int16_t>(ptr);
266 break; 265 break;
267 case kDescriptorUint16Type: 266 case kDescriptorUint16Type:
268 int32_value = *CheckedCast<uint16_t>(ptr); 267 int32_value = *CheckedCast<uint16_t>(ptr);
269 break; 268 break;
270 case kDescriptorInt32Type: 269 case kDescriptorInt32Type:
271 int32_value = *CheckedCast<int32_t>(ptr); 270 int32_value = *CheckedCast<int32_t>(ptr);
272 break; 271 break;
273 case kDescriptorUint32Type: { 272 case kDescriptorUint32Type: {
274 uint32_t value = *CheckedCast<uint32_t>(ptr); 273 uint32_t value = *CheckedCast<uint32_t>(ptr);
275 AllowHeapAllocation allow_gc; 274 return heap->NumberFromUint32(value);
276 return isolate->factory()->NewNumberFromUint(value);
277 } 275 }
278 case kDescriptorBoolType: { 276 case kDescriptorBoolType: {
279 uint8_t byte = *CheckedCast<uint8_t>(ptr); 277 uint8_t byte = *CheckedCast<uint8_t>(ptr);
280 return isolate->factory()->ToBoolean( 278 return heap->ToBoolean(byte & (0x1 << descriptor.bool_offset));
281 byte & (0x1 << descriptor.bool_offset));
282 } 279 }
283 case kDescriptorFloatType: { 280 case kDescriptorFloatType: {
284 float value = *CheckedCast<float>(ptr); 281 float value = *CheckedCast<float>(ptr);
285 AllowHeapAllocation allow_gc; 282 return heap->NumberFromDouble(value);
286 return isolate->factory()->NewNumber(value);
287 } 283 }
288 case kDescriptorDoubleType: { 284 case kDescriptorDoubleType: {
289 double value = *CheckedCast<double>(ptr); 285 double value = *CheckedCast<double>(ptr);
290 AllowHeapAllocation allow_gc; 286 return heap->NumberFromDouble(value);
291 return isolate->factory()->NewNumber(value);
292 } 287 }
293 } 288 }
294 AllowHeapAllocation allow_gc; 289 return heap->NumberFromInt32(int32_value);
295 return isolate->factory()->NewNumberFromInt(int32_value);
296 } 290 }
297 291
298 292
299 static Handle<Object> GetDeclaredAccessorProperty( 293 static MaybeObject* GetDeclaredAccessorProperty(Object* receiver,
300 Handle<Object> receiver, 294 DeclaredAccessorInfo* info,
301 Handle<DeclaredAccessorInfo> info, 295 Isolate* isolate) {
302 Isolate* isolate) { 296 char* current = reinterpret_cast<char*>(receiver);
303 DisallowHeapAllocation no_gc;
304 char* current = reinterpret_cast<char*>(*receiver);
305 DeclaredAccessorDescriptorIterator iterator(info->descriptor()); 297 DeclaredAccessorDescriptorIterator iterator(info->descriptor());
306 while (true) { 298 while (true) {
307 const DeclaredAccessorDescriptorData* data = iterator.Next(); 299 const DeclaredAccessorDescriptorData* data = iterator.Next();
308 switch (data->type) { 300 switch (data->type) {
309 case kDescriptorReturnObject: { 301 case kDescriptorReturnObject: {
310 ASSERT(iterator.Complete()); 302 ASSERT(iterator.Complete());
311 current = *CheckedCast<char*>(current); 303 current = *CheckedCast<char*>(current);
312 return handle(*CheckedCast<Object*>(current), isolate); 304 return *CheckedCast<Object*>(current);
313 } 305 }
314 case kDescriptorPointerDereference: 306 case kDescriptorPointerDereference:
315 ASSERT(!iterator.Complete()); 307 ASSERT(!iterator.Complete());
316 current = *reinterpret_cast<char**>(current); 308 current = *reinterpret_cast<char**>(current);
317 break; 309 break;
318 case kDescriptorPointerShift: 310 case kDescriptorPointerShift:
319 ASSERT(!iterator.Complete()); 311 ASSERT(!iterator.Complete());
320 current += data->pointer_shift_descriptor.byte_offset; 312 current += data->pointer_shift_descriptor.byte_offset;
321 break; 313 break;
322 case kDescriptorObjectDereference: { 314 case kDescriptorObjectDereference: {
323 ASSERT(!iterator.Complete()); 315 ASSERT(!iterator.Complete());
324 Object* object = CheckedCast<Object>(current); 316 Object* object = CheckedCast<Object>(current);
325 int field = data->object_dereference_descriptor.internal_field; 317 int field = data->object_dereference_descriptor.internal_field;
326 Object* smi = JSObject::cast(object)->GetInternalField(field); 318 Object* smi = JSObject::cast(object)->GetInternalField(field);
327 ASSERT(smi->IsSmi()); 319 ASSERT(smi->IsSmi());
328 current = reinterpret_cast<char*>(smi); 320 current = reinterpret_cast<char*>(smi);
329 break; 321 break;
330 } 322 }
331 case kDescriptorBitmaskCompare: 323 case kDescriptorBitmaskCompare:
332 ASSERT(iterator.Complete()); 324 ASSERT(iterator.Complete());
333 return PerformCompare(data->bitmask_compare_descriptor, 325 return PerformCompare(data->bitmask_compare_descriptor,
334 current, 326 current,
335 isolate); 327 isolate->heap());
336 case kDescriptorPointerCompare: 328 case kDescriptorPointerCompare:
337 ASSERT(iterator.Complete()); 329 ASSERT(iterator.Complete());
338 return PerformCompare(data->pointer_compare_descriptor, 330 return PerformCompare(data->pointer_compare_descriptor,
339 current, 331 current,
340 isolate); 332 isolate->heap());
341 case kDescriptorPrimitiveValue: 333 case kDescriptorPrimitiveValue:
342 ASSERT(iterator.Complete()); 334 ASSERT(iterator.Complete());
343 return GetPrimitiveValue(data->primitive_value_descriptor, 335 return GetPrimitiveValue(data->primitive_value_descriptor,
344 current, 336 current,
345 isolate); 337 isolate->heap());
346 } 338 }
347 } 339 }
348 UNREACHABLE(); 340 UNREACHABLE();
349 return isolate->factory()->undefined_value(); 341 return NULL;
350 } 342 }
351 343
352 344
345 static Handle<Object> GetDeclaredAccessorProperty(
346 Handle<Object> receiver,
347 Handle<DeclaredAccessorInfo> info,
348 Isolate* isolate) {
349 CALL_HEAP_FUNCTION(isolate,
350 GetDeclaredAccessorProperty(*receiver, *info, isolate),
351 Object);
352 }
353
354
353 Handle<FixedArray> JSObject::EnsureWritableFastElements( 355 Handle<FixedArray> JSObject::EnsureWritableFastElements(
354 Handle<JSObject> object) { 356 Handle<JSObject> object) {
355 CALL_HEAP_FUNCTION(object->GetIsolate(), 357 CALL_HEAP_FUNCTION(object->GetIsolate(),
356 object->EnsureWritableFastElements(), 358 object->EnsureWritableFastElements(),
357 FixedArray); 359 FixedArray);
358 } 360 }
359 361
360 362
361 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object, 363 MaybeHandle<Object> JSObject::GetPropertyWithCallback(Handle<JSObject> object,
362 Handle<Object> receiver, 364 Handle<Object> receiver,
(...skipping 20 matching lines...) Expand all
383 Handle<Object> error = 385 Handle<Object> error =
384 isolate->factory()->NewTypeError("incompatible_method_receiver", 386 isolate->factory()->NewTypeError("incompatible_method_receiver",
385 HandleVector(args, 387 HandleVector(args,
386 ARRAY_SIZE(args))); 388 ARRAY_SIZE(args)));
387 return isolate->Throw<Object>(error); 389 return isolate->Throw<Object>(error);
388 } 390 }
389 // TODO(rossberg): Handling symbols in the API requires changing the API, 391 // TODO(rossberg): Handling symbols in the API requires changing the API,
390 // so we do not support it for now. 392 // so we do not support it for now.
391 if (name->IsSymbol()) return isolate->factory()->undefined_value(); 393 if (name->IsSymbol()) return isolate->factory()->undefined_value();
392 if (structure->IsDeclaredAccessorInfo()) { 394 if (structure->IsDeclaredAccessorInfo()) {
393 return GetDeclaredAccessorProperty( 395 CALL_HEAP_FUNCTION(
394 receiver, 396 isolate,
395 Handle<DeclaredAccessorInfo>::cast(structure), 397 GetDeclaredAccessorProperty(*receiver,
396 isolate); 398 DeclaredAccessorInfo::cast(*structure),
399 isolate),
400 Object);
397 } 401 }
398 402
399 Handle<ExecutableAccessorInfo> data = 403 Handle<ExecutableAccessorInfo> data =
400 Handle<ExecutableAccessorInfo>::cast(structure); 404 Handle<ExecutableAccessorInfo>::cast(structure);
401 v8::AccessorGetterCallback call_fun = 405 v8::AccessorGetterCallback call_fun =
402 v8::ToCData<v8::AccessorGetterCallback>(data->getter()); 406 v8::ToCData<v8::AccessorGetterCallback>(data->getter());
403 if (call_fun == NULL) return isolate->factory()->undefined_value(); 407 if (call_fun == NULL) return isolate->factory()->undefined_value();
404 408
405 Handle<JSObject> self = Handle<JSObject>::cast(receiver); 409 Handle<JSObject> self = Handle<JSObject>::cast(receiver);
406 Handle<String> key = Handle<String>::cast(name); 410 Handle<String> key = Handle<String>::cast(name);
(...skipping 16079 matching lines...) Expand 10 before | Expand all | Expand 10 after
16486 #define ERROR_MESSAGES_TEXTS(C, T) T, 16490 #define ERROR_MESSAGES_TEXTS(C, T) T,
16487 static const char* error_messages_[] = { 16491 static const char* error_messages_[] = {
16488 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16492 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16489 }; 16493 };
16490 #undef ERROR_MESSAGES_TEXTS 16494 #undef ERROR_MESSAGES_TEXTS
16491 return error_messages_[reason]; 16495 return error_messages_[reason];
16492 } 16496 }
16493 16497
16494 16498
16495 } } // namespace v8::internal 16499 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698