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

Side by Side Diff: src/objects.cc

Issue 12328064: Remove duplication and unnecessary HandleScope from HasElement helper functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added test for StringWithCharacterAt Created 7 years, 9 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 | test/cctest/test-api.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 // 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 3352 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 ASSERT(proto->IsJSGlobalObject()); 3363 ASSERT(proto->IsJSGlobalObject());
3364 return JSObject::cast(proto)->GetElementAttributeWithReceiver( 3364 return JSObject::cast(proto)->GetElementAttributeWithReceiver(
3365 receiver, index, continue_search); 3365 receiver, index, continue_search);
3366 } 3366 }
3367 3367
3368 // Check for lookup interceptor except when bootstrapping. 3368 // Check for lookup interceptor except when bootstrapping.
3369 if (HasIndexedInterceptor() && !isolate->bootstrapper()->IsActive()) { 3369 if (HasIndexedInterceptor() && !isolate->bootstrapper()->IsActive()) {
3370 return GetElementAttributeWithInterceptor(receiver, index, continue_search); 3370 return GetElementAttributeWithInterceptor(receiver, index, continue_search);
3371 } 3371 }
3372 3372
3373 // Handle [] on String objects.
3374 if (this->IsStringObjectWithCharacterAt(index)) {
3375 return static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
3376 }
3377
3378 return GetElementAttributeWithoutInterceptor( 3373 return GetElementAttributeWithoutInterceptor(
3379 receiver, index, continue_search); 3374 receiver, index, continue_search);
3380 } 3375 }
3381 3376
3382 3377
3383 PropertyAttributes JSObject::GetElementAttributeWithInterceptor( 3378 PropertyAttributes JSObject::GetElementAttributeWithInterceptor(
3384 JSReceiver* receiver, uint32_t index, bool continue_search) { 3379 JSReceiver* receiver, uint32_t index, bool continue_search) {
3385 Isolate* isolate = GetIsolate(); 3380 Isolate* isolate = GetIsolate();
3386 // Make sure that the top context does not change when doing 3381 // Make sure that the top context does not change when doing
3387 // callbacks or interceptor calls. 3382 // callbacks or interceptor calls.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 if (!result.IsEmpty()) return NONE; 3414 if (!result.IsEmpty()) return NONE;
3420 } 3415 }
3421 3416
3422 return holder->GetElementAttributeWithoutInterceptor( 3417 return holder->GetElementAttributeWithoutInterceptor(
3423 *hreceiver, index, continue_search); 3418 *hreceiver, index, continue_search);
3424 } 3419 }
3425 3420
3426 3421
3427 PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor( 3422 PropertyAttributes JSObject::GetElementAttributeWithoutInterceptor(
3428 JSReceiver* receiver, uint32_t index, bool continue_search) { 3423 JSReceiver* receiver, uint32_t index, bool continue_search) {
3429 Isolate* isolate = GetIsolate(); 3424 PropertyAttributes attr = GetElementsAccessor()->GetAttributes(
3430 HandleScope scope(isolate); 3425 receiver, this, index);
3431 Handle<JSReceiver> hreceiver(receiver);
3432 Handle<JSObject> holder(this);
3433 PropertyAttributes attr = holder->GetElementsAccessor()->GetAttributes(
3434 *hreceiver, *holder, index);
3435 if (attr != ABSENT) return attr; 3426 if (attr != ABSENT) return attr;
3436 3427
3437 if (holder->IsStringObjectWithCharacterAt(index)) { 3428 // Handle [] on String objects.
3429 if (IsStringObjectWithCharacterAt(index)) {
3438 return static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE); 3430 return static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
3439 } 3431 }
3440 3432
3441 if (!continue_search) return ABSENT; 3433 if (!continue_search) return ABSENT;
3442 3434
3443 Object* pt = holder->GetPrototype(); 3435 Object* pt = GetPrototype();
3444 if (pt->IsJSProxy()) { 3436 if (pt->IsJSProxy()) {
3445 // We need to follow the spec and simulate a call to [[GetOwnProperty]]. 3437 // We need to follow the spec and simulate a call to [[GetOwnProperty]].
3446 return JSProxy::cast(pt)->GetElementAttributeWithHandler(*hreceiver, index); 3438 return JSProxy::cast(pt)->GetElementAttributeWithHandler(receiver, index);
3447 } 3439 }
3448 if (pt->IsNull()) return ABSENT; 3440 if (pt->IsNull()) return ABSENT;
3449 return JSObject::cast(pt)->GetElementAttributeWithReceiver( 3441 return JSObject::cast(pt)->GetElementAttributeWithReceiver(
3450 *hreceiver, index, true); 3442 receiver, index, true);
3451 } 3443 }
3452 3444
3453 3445
3454 MaybeObject* NormalizedMapCache::Get(JSObject* obj, 3446 MaybeObject* NormalizedMapCache::Get(JSObject* obj,
3455 PropertyNormalizationMode mode) { 3447 PropertyNormalizationMode mode) {
3456 Isolate* isolate = obj->GetIsolate(); 3448 Isolate* isolate = obj->GetIsolate();
3457 Map* fast = obj->map(); 3449 Map* fast = obj->map();
3458 int index = fast->Hash() % kEntries; 3450 int index = fast->Hash() % kEntries;
3459 Object* result = get(index); 3451 Object* result = get(index);
3460 if (result->IsMap() && 3452 if (result->IsMap() &&
(...skipping 10523 matching lines...) Expand 10 before | Expand all | Expand 10 after
13984 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13976 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13985 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13977 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13986 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13978 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13987 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13979 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13988 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13980 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13989 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13981 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13990 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13982 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13991 } 13983 }
13992 13984
13993 } } // namespace v8::internal 13985 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698