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

Side by Side Diff: src/api.cc

Issue 10918169: Refactored fast external string resource getter. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/objects-inl.h » ('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 4069 matching lines...) Expand 10 before | Expand all | Expand 10 after
4080 if (i::StringShape(*str).IsExternalTwoByte()) { 4080 if (i::StringShape(*str).IsExternalTwoByte()) {
4081 const void* resource = 4081 const void* resource =
4082 i::Handle<i::ExternalTwoByteString>::cast(str)->resource(); 4082 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4083 expected = reinterpret_cast<const ExternalStringResource*>(resource); 4083 expected = reinterpret_cast<const ExternalStringResource*>(resource);
4084 } else { 4084 } else {
4085 expected = NULL; 4085 expected = NULL;
4086 } 4086 }
4087 CHECK_EQ(expected, value); 4087 CHECK_EQ(expected, value);
4088 } 4088 }
4089 4089
4090 void v8::String::VerifyExternalStringResourceBase(
4091 v8::String::ExternalStringResourceBase* value,
4092 int type) const {
4093 i::Handle<i::String> str = Utils::OpenHandle(this);
4094 const v8::String::ExternalStringResourceBase* expected;
4095 int expectedType;
4096 if (i::StringShape(*str).IsExternalAscii()) {
4097 const void* resource =
4098 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4099 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4100 expectedType = kExternalAsciiStringType;
4101 } else if (i::StringShape(*str).IsExternalTwoByte()) {
4102 const void* resource =
4103 i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
4104 expected = reinterpret_cast<const ExternalStringResourceBase*>(resource);
4105 expectedType = kExternalTwoByteStringType;
4106 } else {
4107 expected = NULL;
4108 expectedType = 0;
4109 }
4110 CHECK_EQ(expected, value);
4111 CHECK_EQ(expectedType, type);
4112 }
4090 4113
4091 const v8::String::ExternalAsciiStringResource* 4114 const v8::String::ExternalAsciiStringResource*
4092 v8::String::GetExternalAsciiStringResource() const { 4115 v8::String::GetExternalAsciiStringResource() const {
4093 i::Handle<i::String> str = Utils::OpenHandle(this); 4116 i::Handle<i::String> str = Utils::OpenHandle(this);
4094 if (IsDeadCheck(str->GetIsolate(), 4117 if (IsDeadCheck(str->GetIsolate(),
4095 "v8::String::GetExternalAsciiStringResource()")) { 4118 "v8::String::GetExternalAsciiStringResource()")) {
4096 return NULL; 4119 return NULL;
4097 } 4120 }
4098 if (i::StringShape(*str).IsExternalAscii()) { 4121 if (i::StringShape(*str).IsExternalAscii()) {
4099 const void* resource = 4122 const void* resource =
(...skipping 2452 matching lines...) Expand 10 before | Expand all | Expand 10 after
6552 6575
6553 v->VisitPointers(blocks_.first(), first_block_limit_); 6576 v->VisitPointers(blocks_.first(), first_block_limit_);
6554 6577
6555 for (int i = 1; i < blocks_.length(); i++) { 6578 for (int i = 1; i < blocks_.length(); i++) {
6556 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6579 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6557 } 6580 }
6558 } 6581 }
6559 6582
6560 6583
6561 } } // namespace v8::internal 6584 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698