Restructure tables for C89 port and smaller size.

Changes the data layout of tables slightly so that string
keys are prefixed with their size, rather than the size
being inline in the table itself.

This has a few benefits:

1. inttables shrink a bit, because there is no longer a wasted
   and unused size field sitting in them.

2. This avoids the need to have a union in the table.  This is
   important for an impending C89 port of upb, since C89 has
   literally no way of statically initializing a non-first union
   member.
pull/13171/head
Josh Haberman 10 years ago
parent 0c7eb664fc
commit e2840a4aa1
  1. 2
      tests/test_table.cc
  2. 22
      tools/dump_cinit.lua
  3. 3
      travis.sh
  4. 6
      upb/bindings/lua/upb/table.c
  5. 264
      upb/descriptor/descriptor.upb.c
  6. 76
      upb/table.c
  7. 69
      upb/table.int.h

@ -62,6 +62,8 @@ void test_strtable(const vector<std::string>& keys, uint32_t num_to_insert) {
upb_strtable_next(&iter)) {
const char *key = upb_strtable_iter_key(&iter);
std::string tmp(key, strlen(key));
std::string tmp2(key, upb_strtable_iter_keylength(&iter));
ASSERT(tmp == tmp2);
std::set<std::string>::iterator i = all.find(tmp);
ASSERT(i != all.end());
all.erase(i);

@ -47,6 +47,20 @@ function handler_types(base)
return ret
end
function octchar(num)
assert(num < 8)
local idx = num + 1 -- 1-based index
return string.sub("01234567", idx, idx)
end
function c_escape(num)
assert(num < 256)
return string.format("\\%s%s%s",
octchar(math.floor(num / 64)),
octchar(math.floor(num / 8) % 8),
octchar(num % 8));
end
-- const(f, label) -> UPB_LABEL_REPEATED, where f:label() == upb.LABEL_REPEATED
function const(obj, name, base)
local val = obj[name]
@ -214,7 +228,13 @@ function Dumper:tabkey(key)
if type(key) == "nil" then
return "UPB_TABKEY_NONE"
elseif type(key) == "string" then
return string.format('UPB_TABKEY_STR("%s")', key)
local len = #key
local len1 = c_escape(len % 256)
local len2 = c_escape(math.floor(len / 256) % 256)
local len3 = c_escape(math.floor(len / (256 * 256)) % 256)
local len4 = c_escape(math.floor(len / (256 * 256 * 256)) % 256)
return string.format('UPB_TABKEY_STR("%s", "%s", "%s", "%s", "%s")',
len1, len2, len3, len4, key)
else
return string.format("UPB_TABKEY_NUM(%d)", key)
end

@ -104,6 +104,9 @@ coverage_after_success() {
set -e
set -x
$CC --version
$CXX --version
if [ "$1" == "after_failure" ]; then
# Upload failing tree to S3.
curl -sL https://raw.githubusercontent.com/travis-ci/artifacts/master/install | bash

@ -66,9 +66,11 @@ static void lupbtable_pushent(lua_State *L, const upb_tabent *e,
lua_newtable(L);
if (!upb_tabent_isempty(e)) {
if (inttab) {
lua_pushnumber(L, e->key.num);
lua_pushnumber(L, e->key);
} else {
lua_pushlstring(L, e->key.s.str, e->key.s.length);
uint32_t len;
const char *str = upb_tabstr(e->key, &len);
lua_pushlstring(L, str, len);
}
lua_setfield(L, -2, "key");
lupbtable_pushval(L, e->val, ctype);

@ -131,242 +131,242 @@ static const upb_enumdef enums[4] = {
};
static const upb_tabent strentries[236] = {
{UPB_TABKEY_STR("extension"), UPB_VALUE_INIT_CONSTPTR(&fields[14]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_VALUE_INIT_CONSTPTR(&fields[14]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[38]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[38]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("field"), UPB_VALUE_INIT_CONSTPTR(&fields[16]), NULL},
{UPB_TABKEY_STR("extension_range"), UPB_VALUE_INIT_CONSTPTR(&fields[15]), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "field"), UPB_VALUE_INIT_CONSTPTR(&fields[16]), NULL},
{UPB_TABKEY_STR("\017", "\000", "\000", "\000", "extension_range"), UPB_VALUE_INIT_CONSTPTR(&fields[15]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("nested_type"), UPB_VALUE_INIT_CONSTPTR(&fields[44]), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "nested_type"), UPB_VALUE_INIT_CONSTPTR(&fields[44]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[49]), NULL},
{UPB_TABKEY_STR("enum_type"), UPB_VALUE_INIT_CONSTPTR(&fields[9]), &strentries[14]},
{UPB_TABKEY_STR("start"), UPB_VALUE_INIT_CONSTPTR(&fields[66]), NULL},
{UPB_TABKEY_STR("end"), UPB_VALUE_INIT_CONSTPTR(&fields[8]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[49]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_VALUE_INIT_CONSTPTR(&fields[9]), &strentries[14]},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "start"), UPB_VALUE_INIT_CONSTPTR(&fields[66]), NULL},
{UPB_TABKEY_STR("\003", "\000", "\000", "\000", "end"), UPB_VALUE_INIT_CONSTPTR(&fields[8]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("value"), UPB_VALUE_INIT_CONSTPTR(&fields[78]), NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[50]), NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[40]), &strentries[22]},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[73]), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "value"), UPB_VALUE_INIT_CONSTPTR(&fields[78]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[50]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[40]), &strentries[22]},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[73]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("allow_alias"), UPB_VALUE_INIT_CONSTPTR(&fields[1]), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "allow_alias"), UPB_VALUE_INIT_CONSTPTR(&fields[1]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("number"), UPB_VALUE_INIT_CONSTPTR(&fields[47]), NULL},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_VALUE_INIT_CONSTPTR(&fields[47]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[52]), NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[37]), &strentries[30]},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[71]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[52]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[37]), &strentries[30]},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[71]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("label"), UPB_VALUE_INIT_CONSTPTR(&fields[27]), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "label"), UPB_VALUE_INIT_CONSTPTR(&fields[27]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[41]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[41]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("number"), UPB_VALUE_INIT_CONSTPTR(&fields[46]), &strentries[49]},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "number"), UPB_VALUE_INIT_CONSTPTR(&fields[46]), &strentries[49]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("type_name"), UPB_VALUE_INIT_CONSTPTR(&fields[70]), NULL},
{UPB_TABKEY_STR("extendee"), UPB_VALUE_INIT_CONSTPTR(&fields[12]), NULL},
{UPB_TABKEY_STR("type"), UPB_VALUE_INIT_CONSTPTR(&fields[69]), &strentries[48]},
{UPB_TABKEY_STR("default_value"), UPB_VALUE_INIT_CONSTPTR(&fields[4]), NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[51]), NULL},
{UPB_TABKEY_STR("experimental_map_key"), UPB_VALUE_INIT_CONSTPTR(&fields[11]), &strentries[67]},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "type_name"), UPB_VALUE_INIT_CONSTPTR(&fields[70]), NULL},
{UPB_TABKEY_STR("\010", "\000", "\000", "\000", "extendee"), UPB_VALUE_INIT_CONSTPTR(&fields[12]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "type"), UPB_VALUE_INIT_CONSTPTR(&fields[69]), &strentries[48]},
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "default_value"), UPB_VALUE_INIT_CONSTPTR(&fields[4]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[51]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "experimental_map_key"), UPB_VALUE_INIT_CONSTPTR(&fields[11]), &strentries[67]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("weak"), UPB_VALUE_INIT_CONSTPTR(&fields[79]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "weak"), UPB_VALUE_INIT_CONSTPTR(&fields[79]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("packed"), UPB_VALUE_INIT_CONSTPTR(&fields[58]), NULL},
{UPB_TABKEY_STR("lazy"), UPB_VALUE_INIT_CONSTPTR(&fields[28]), NULL},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "packed"), UPB_VALUE_INIT_CONSTPTR(&fields[58]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "lazy"), UPB_VALUE_INIT_CONSTPTR(&fields[28]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("ctype"), UPB_VALUE_INIT_CONSTPTR(&fields[3]), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "ctype"), UPB_VALUE_INIT_CONSTPTR(&fields[3]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("deprecated"), UPB_VALUE_INIT_CONSTPTR(&fields[6]), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "deprecated"), UPB_VALUE_INIT_CONSTPTR(&fields[6]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[77]), NULL},
{UPB_TABKEY_STR("extension"), UPB_VALUE_INIT_CONSTPTR(&fields[13]), NULL},
{UPB_TABKEY_STR("weak_dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[80]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[77]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "extension"), UPB_VALUE_INIT_CONSTPTR(&fields[13]), NULL},
{UPB_TABKEY_STR("\017", "\000", "\000", "\000", "weak_dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[80]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[34]), NULL},
{UPB_TABKEY_STR("service"), UPB_VALUE_INIT_CONSTPTR(&fields[63]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[34]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "service"), UPB_VALUE_INIT_CONSTPTR(&fields[63]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("source_code_info"), UPB_VALUE_INIT_CONSTPTR(&fields[64]), NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "source_code_info"), UPB_VALUE_INIT_CONSTPTR(&fields[64]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[5]), NULL},
{UPB_TABKEY_STR("message_type"), UPB_VALUE_INIT_CONSTPTR(&fields[32]), NULL},
{UPB_TABKEY_STR("package"), UPB_VALUE_INIT_CONSTPTR(&fields[57]), NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[53]), &strentries[82]},
{UPB_TABKEY_STR("enum_type"), UPB_VALUE_INIT_CONSTPTR(&fields[10]), NULL},
{UPB_TABKEY_STR("public_dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[61]), &strentries[81]},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[5]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "message_type"), UPB_VALUE_INIT_CONSTPTR(&fields[32]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "package"), UPB_VALUE_INIT_CONSTPTR(&fields[57]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[53]), &strentries[82]},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "enum_type"), UPB_VALUE_INIT_CONSTPTR(&fields[10]), NULL},
{UPB_TABKEY_STR("\021", "\000", "\000", "\000", "public_dependency"), UPB_VALUE_INIT_CONSTPTR(&fields[61]), &strentries[81]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("file"), UPB_VALUE_INIT_CONSTPTR(&fields[17]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "file"), UPB_VALUE_INIT_CONSTPTR(&fields[17]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[75]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[75]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("cc_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[2]), NULL},
{UPB_TABKEY_STR("\023", "\000", "\000", "\000", "cc_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[2]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("java_multiple_files"), UPB_VALUE_INIT_CONSTPTR(&fields[24]), NULL},
{UPB_TABKEY_STR("\023", "\000", "\000", "\000", "java_multiple_files"), UPB_VALUE_INIT_CONSTPTR(&fields[24]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("java_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[23]), &strentries[102]},
{UPB_TABKEY_STR("java_generate_equals_and_hash"), UPB_VALUE_INIT_CONSTPTR(&fields[22]), NULL},
{UPB_TABKEY_STR("\025", "\000", "\000", "\000", "java_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[23]), &strentries[102]},
{UPB_TABKEY_STR("\035", "\000", "\000", "\000", "java_generate_equals_and_hash"), UPB_VALUE_INIT_CONSTPTR(&fields[22]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("go_package"), UPB_VALUE_INIT_CONSTPTR(&fields[18]), NULL},
{UPB_TABKEY_STR("java_package"), UPB_VALUE_INIT_CONSTPTR(&fields[26]), NULL},
{UPB_TABKEY_STR("optimize_for"), UPB_VALUE_INIT_CONSTPTR(&fields[48]), NULL},
{UPB_TABKEY_STR("py_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[62]), NULL},
{UPB_TABKEY_STR("java_outer_classname"), UPB_VALUE_INIT_CONSTPTR(&fields[25]), NULL},
{UPB_TABKEY_STR("message_set_wire_format"), UPB_VALUE_INIT_CONSTPTR(&fields[31]), &strentries[106]},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "go_package"), UPB_VALUE_INIT_CONSTPTR(&fields[18]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "java_package"), UPB_VALUE_INIT_CONSTPTR(&fields[26]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "optimize_for"), UPB_VALUE_INIT_CONSTPTR(&fields[48]), NULL},
{UPB_TABKEY_STR("\023", "\000", "\000", "\000", "py_generic_services"), UPB_VALUE_INIT_CONSTPTR(&fields[62]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "java_outer_classname"), UPB_VALUE_INIT_CONSTPTR(&fields[25]), NULL},
{UPB_TABKEY_STR("\027", "\000", "\000", "\000", "message_set_wire_format"), UPB_VALUE_INIT_CONSTPTR(&fields[31]), &strentries[106]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[76]), NULL},
{UPB_TABKEY_STR("no_standard_descriptor_accessor"), UPB_VALUE_INIT_CONSTPTR(&fields[45]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[76]), NULL},
{UPB_TABKEY_STR("\037", "\000", "\000", "\000", "no_standard_descriptor_accessor"), UPB_VALUE_INIT_CONSTPTR(&fields[45]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[39]), NULL},
{UPB_TABKEY_STR("input_type"), UPB_VALUE_INIT_CONSTPTR(&fields[20]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[39]), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "input_type"), UPB_VALUE_INIT_CONSTPTR(&fields[20]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("output_type"), UPB_VALUE_INIT_CONSTPTR(&fields[56]), NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[55]), NULL},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[74]), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "output_type"), UPB_VALUE_INIT_CONSTPTR(&fields[56]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[55]), NULL},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[74]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("options"), UPB_VALUE_INIT_CONSTPTR(&fields[54]), &strentries[122]},
{UPB_TABKEY_STR("method"), UPB_VALUE_INIT_CONSTPTR(&fields[33]), NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[35]), &strentries[121]},
{UPB_TABKEY_STR("uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[72]), NULL},
{UPB_TABKEY_STR("\007", "\000", "\000", "\000", "options"), UPB_VALUE_INIT_CONSTPTR(&fields[54]), &strentries[122]},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "method"), UPB_VALUE_INIT_CONSTPTR(&fields[33]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[35]), &strentries[121]},
{UPB_TABKEY_STR("\024", "\000", "\000", "\000", "uninterpreted_option"), UPB_VALUE_INIT_CONSTPTR(&fields[72]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("location"), UPB_VALUE_INIT_CONSTPTR(&fields[30]), NULL},
{UPB_TABKEY_STR("\010", "\000", "\000", "\000", "location"), UPB_VALUE_INIT_CONSTPTR(&fields[30]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("span"), UPB_VALUE_INIT_CONSTPTR(&fields[65]), &strentries[139]},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "span"), UPB_VALUE_INIT_CONSTPTR(&fields[65]), &strentries[139]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("trailing_comments"), UPB_VALUE_INIT_CONSTPTR(&fields[68]), NULL},
{UPB_TABKEY_STR("leading_comments"), UPB_VALUE_INIT_CONSTPTR(&fields[29]), &strentries[137]},
{UPB_TABKEY_STR("path"), UPB_VALUE_INIT_CONSTPTR(&fields[59]), NULL},
{UPB_TABKEY_STR("double_value"), UPB_VALUE_INIT_CONSTPTR(&fields[7]), NULL},
{UPB_TABKEY_STR("\021", "\000", "\000", "\000", "trailing_comments"), UPB_VALUE_INIT_CONSTPTR(&fields[68]), NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "leading_comments"), UPB_VALUE_INIT_CONSTPTR(&fields[29]), &strentries[137]},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "path"), UPB_VALUE_INIT_CONSTPTR(&fields[59]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "double_value"), UPB_VALUE_INIT_CONSTPTR(&fields[7]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("name"), UPB_VALUE_INIT_CONSTPTR(&fields[36]), NULL},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "name"), UPB_VALUE_INIT_CONSTPTR(&fields[36]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("negative_int_value"), UPB_VALUE_INIT_CONSTPTR(&fields[43]), NULL},
{UPB_TABKEY_STR("aggregate_value"), UPB_VALUE_INIT_CONSTPTR(&fields[0]), NULL},
{UPB_TABKEY_STR("\022", "\000", "\000", "\000", "negative_int_value"), UPB_VALUE_INIT_CONSTPTR(&fields[43]), NULL},
{UPB_TABKEY_STR("\017", "\000", "\000", "\000", "aggregate_value"), UPB_VALUE_INIT_CONSTPTR(&fields[0]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("positive_int_value"), UPB_VALUE_INIT_CONSTPTR(&fields[60]), NULL},
{UPB_TABKEY_STR("identifier_value"), UPB_VALUE_INIT_CONSTPTR(&fields[19]), NULL},
{UPB_TABKEY_STR("string_value"), UPB_VALUE_INIT_CONSTPTR(&fields[67]), &strentries[154]},
{UPB_TABKEY_STR("\022", "\000", "\000", "\000", "positive_int_value"), UPB_VALUE_INIT_CONSTPTR(&fields[60]), NULL},
{UPB_TABKEY_STR("\020", "\000", "\000", "\000", "identifier_value"), UPB_VALUE_INIT_CONSTPTR(&fields[19]), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "string_value"), UPB_VALUE_INIT_CONSTPTR(&fields[67]), &strentries[154]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("is_extension"), UPB_VALUE_INIT_CONSTPTR(&fields[21]), NULL},
{UPB_TABKEY_STR("name_part"), UPB_VALUE_INIT_CONSTPTR(&fields[42]), NULL},
{UPB_TABKEY_STR("LABEL_REQUIRED"), UPB_VALUE_INIT_INT32(2), &strentries[162]},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "is_extension"), UPB_VALUE_INIT_CONSTPTR(&fields[21]), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "name_part"), UPB_VALUE_INIT_CONSTPTR(&fields[42]), NULL},
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REQUIRED"), UPB_VALUE_INIT_INT32(2), &strentries[162]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("LABEL_REPEATED"), UPB_VALUE_INIT_INT32(3), NULL},
{UPB_TABKEY_STR("LABEL_OPTIONAL"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_STR("TYPE_FIXED64"), UPB_VALUE_INIT_INT32(6), NULL},
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_REPEATED"), UPB_VALUE_INIT_INT32(3), NULL},
{UPB_TABKEY_STR("\016", "\000", "\000", "\000", "LABEL_OPTIONAL"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_FIXED64"), UPB_VALUE_INIT_INT32(6), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_STRING"), UPB_VALUE_INIT_INT32(9), NULL},
{UPB_TABKEY_STR("TYPE_FLOAT"), UPB_VALUE_INIT_INT32(2), &strentries[193]},
{UPB_TABKEY_STR("TYPE_DOUBLE"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_STRING"), UPB_VALUE_INIT_INT32(9), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_FLOAT"), UPB_VALUE_INIT_INT32(2), &strentries[193]},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_DOUBLE"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_INT32"), UPB_VALUE_INIT_INT32(5), NULL},
{UPB_TABKEY_STR("TYPE_SFIXED32"), UPB_VALUE_INIT_INT32(15), NULL},
{UPB_TABKEY_STR("TYPE_FIXED32"), UPB_VALUE_INIT_INT32(7), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT32"), UPB_VALUE_INIT_INT32(5), NULL},
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED32"), UPB_VALUE_INIT_INT32(15), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_FIXED32"), UPB_VALUE_INIT_INT32(7), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_MESSAGE"), UPB_VALUE_INIT_INT32(11), &strentries[194]},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "TYPE_MESSAGE"), UPB_VALUE_INIT_INT32(11), &strentries[194]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_INT64"), UPB_VALUE_INIT_INT32(3), &strentries[191]},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_INT64"), UPB_VALUE_INIT_INT32(3), &strentries[191]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_ENUM"), UPB_VALUE_INIT_INT32(14), NULL},
{UPB_TABKEY_STR("TYPE_UINT32"), UPB_VALUE_INIT_INT32(13), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "TYPE_ENUM"), UPB_VALUE_INIT_INT32(14), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT32"), UPB_VALUE_INIT_INT32(13), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_UINT64"), UPB_VALUE_INIT_INT32(4), &strentries[190]},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_UINT64"), UPB_VALUE_INIT_INT32(4), &strentries[190]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("TYPE_SFIXED64"), UPB_VALUE_INIT_INT32(16), NULL},
{UPB_TABKEY_STR("TYPE_BYTES"), UPB_VALUE_INIT_INT32(12), NULL},
{UPB_TABKEY_STR("TYPE_SINT64"), UPB_VALUE_INIT_INT32(18), NULL},
{UPB_TABKEY_STR("TYPE_BOOL"), UPB_VALUE_INIT_INT32(8), NULL},
{UPB_TABKEY_STR("TYPE_GROUP"), UPB_VALUE_INIT_INT32(10), NULL},
{UPB_TABKEY_STR("TYPE_SINT32"), UPB_VALUE_INIT_INT32(17), NULL},
{UPB_TABKEY_STR("\015", "\000", "\000", "\000", "TYPE_SFIXED64"), UPB_VALUE_INIT_INT32(16), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_BYTES"), UPB_VALUE_INIT_INT32(12), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_SINT64"), UPB_VALUE_INIT_INT32(18), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "TYPE_BOOL"), UPB_VALUE_INIT_INT32(8), NULL},
{UPB_TABKEY_STR("\012", "\000", "\000", "\000", "TYPE_GROUP"), UPB_VALUE_INIT_INT32(10), NULL},
{UPB_TABKEY_STR("\013", "\000", "\000", "\000", "TYPE_SINT32"), UPB_VALUE_INIT_INT32(17), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("CORD"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_STR("STRING"), UPB_VALUE_INIT_INT32(0), &strentries[197]},
{UPB_TABKEY_STR("STRING_PIECE"), UPB_VALUE_INIT_INT32(2), NULL},
{UPB_TABKEY_STR("CODE_SIZE"), UPB_VALUE_INIT_INT32(2), NULL},
{UPB_TABKEY_STR("SPEED"), UPB_VALUE_INIT_INT32(1), &strentries[203]},
{UPB_TABKEY_STR("\004", "\000", "\000", "\000", "CORD"), UPB_VALUE_INIT_INT32(1), NULL},
{UPB_TABKEY_STR("\006", "\000", "\000", "\000", "STRING"), UPB_VALUE_INIT_INT32(0), &strentries[197]},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "STRING_PIECE"), UPB_VALUE_INIT_INT32(2), NULL},
{UPB_TABKEY_STR("\011", "\000", "\000", "\000", "CODE_SIZE"), UPB_VALUE_INIT_INT32(2), NULL},
{UPB_TABKEY_STR("\005", "\000", "\000", "\000", "SPEED"), UPB_VALUE_INIT_INT32(1), &strentries[203]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("LITE_RUNTIME"), UPB_VALUE_INIT_INT32(3), NULL},
{UPB_TABKEY_STR("\014", "\000", "\000", "\000", "LITE_RUNTIME"), UPB_VALUE_INIT_INT32(3), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("google.protobuf.SourceCodeInfo.Location"), UPB_VALUE_INIT_CONSTPTR(&msgs[17]), NULL},
{UPB_TABKEY_STR("google.protobuf.UninterpretedOption"), UPB_VALUE_INIT_CONSTPTR(&msgs[18]), NULL},
{UPB_TABKEY_STR("google.protobuf.FileDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[8]), NULL},
{UPB_TABKEY_STR("google.protobuf.MethodDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[12]), NULL},
{UPB_TABKEY_STR("\047", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo.Location"), UPB_VALUE_INIT_CONSTPTR(&msgs[17]), NULL},
{UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.UninterpretedOption"), UPB_VALUE_INIT_CONSTPTR(&msgs[18]), NULL},
{UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.FileDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[8]), NULL},
{UPB_TABKEY_STR("\045", "\000", "\000", "\000", "google.protobuf.MethodDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[12]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("google.protobuf.EnumValueOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[5]), NULL},
{UPB_TABKEY_STR("\040", "\000", "\000", "\000", "google.protobuf.EnumValueOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[5]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("google.protobuf.DescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[0]), &strentries[228]},
{UPB_TABKEY_STR("\037", "\000", "\000", "\000", "google.protobuf.DescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[0]), &strentries[228]},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("google.protobuf.SourceCodeInfo"), UPB_VALUE_INIT_CONSTPTR(&msgs[16]), NULL},
{UPB_TABKEY_STR("google.protobuf.FieldDescriptorProto.Type"), UPB_VALUE_INIT_CONSTPTR(&enums[1]), NULL},
{UPB_TABKEY_STR("google.protobuf.DescriptorProto.ExtensionRange"), UPB_VALUE_INIT_CONSTPTR(&msgs[1]), NULL},
{UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.SourceCodeInfo"), UPB_VALUE_INIT_CONSTPTR(&msgs[16]), NULL},
{UPB_TABKEY_STR("\051", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Type"), UPB_VALUE_INIT_CONSTPTR(&enums[1]), NULL},
{UPB_TABKEY_STR("\056", "\000", "\000", "\000", "google.protobuf.DescriptorProto.ExtensionRange"), UPB_VALUE_INIT_CONSTPTR(&msgs[1]), NULL},
{UPB_TABKEY_NONE, UPB__VALUE_INIT_NONE, NULL},
{UPB_TABKEY_STR("google.protobuf.EnumValueDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[4]), NULL},
{UPB_TABKEY_STR("google.protobuf.FieldOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[7]), NULL},
{UPB_TABKEY_STR("google.protobuf.FileOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[10]), NULL},
{UPB_TABKEY_STR("google.protobuf.EnumDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[2]), &strentries[233]},
{UPB_TABKEY_STR("google.protobuf.FieldDescriptorProto.Label"), UPB_VALUE_INIT_CONSTPTR(&enums[0]), NULL},
{UPB_TABKEY_STR("google.protobuf.ServiceDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[14]), NULL},
{UPB_TABKEY_STR("google.protobuf.FieldOptions.CType"), UPB_VALUE_INIT_CONSTPTR(&enums[2]), &strentries[229]},
{UPB_TABKEY_STR("google.protobuf.FileDescriptorSet"), UPB_VALUE_INIT_CONSTPTR(&msgs[9]), &strentries[235]},
{UPB_TABKEY_STR("google.protobuf.EnumOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[3]), NULL},
{UPB_TABKEY_STR("google.protobuf.FieldDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[6]), NULL},
{UPB_TABKEY_STR("google.protobuf.FileOptions.OptimizeMode"), UPB_VALUE_INIT_CONSTPTR(&enums[3]), &strentries[221]},
{UPB_TABKEY_STR("google.protobuf.ServiceOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[15]), NULL},
{UPB_TABKEY_STR("google.protobuf.MessageOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[11]), NULL},
{UPB_TABKEY_STR("google.protobuf.MethodOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[13]), &strentries[226]},
{UPB_TABKEY_STR("google.protobuf.UninterpretedOption.NamePart"), UPB_VALUE_INIT_CONSTPTR(&msgs[19]), NULL},
{UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.EnumValueDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[4]), NULL},
{UPB_TABKEY_STR("\034", "\000", "\000", "\000", "google.protobuf.FieldOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[7]), NULL},
{UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.FileOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[10]), NULL},
{UPB_TABKEY_STR("\043", "\000", "\000", "\000", "google.protobuf.EnumDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[2]), &strentries[233]},
{UPB_TABKEY_STR("\052", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto.Label"), UPB_VALUE_INIT_CONSTPTR(&enums[0]), NULL},
{UPB_TABKEY_STR("\046", "\000", "\000", "\000", "google.protobuf.ServiceDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[14]), NULL},
{UPB_TABKEY_STR("\042", "\000", "\000", "\000", "google.protobuf.FieldOptions.CType"), UPB_VALUE_INIT_CONSTPTR(&enums[2]), &strentries[229]},
{UPB_TABKEY_STR("\041", "\000", "\000", "\000", "google.protobuf.FileDescriptorSet"), UPB_VALUE_INIT_CONSTPTR(&msgs[9]), &strentries[235]},
{UPB_TABKEY_STR("\033", "\000", "\000", "\000", "google.protobuf.EnumOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[3]), NULL},
{UPB_TABKEY_STR("\044", "\000", "\000", "\000", "google.protobuf.FieldDescriptorProto"), UPB_VALUE_INIT_CONSTPTR(&msgs[6]), NULL},
{UPB_TABKEY_STR("\050", "\000", "\000", "\000", "google.protobuf.FileOptions.OptimizeMode"), UPB_VALUE_INIT_CONSTPTR(&enums[3]), &strentries[221]},
{UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.ServiceOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[15]), NULL},
{UPB_TABKEY_STR("\036", "\000", "\000", "\000", "google.protobuf.MessageOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[11]), NULL},
{UPB_TABKEY_STR("\035", "\000", "\000", "\000", "google.protobuf.MethodOptions"), UPB_VALUE_INIT_CONSTPTR(&msgs[13]), &strentries[226]},
{UPB_TABKEY_STR("\054", "\000", "\000", "\000", "google.protobuf.UninterpretedOption.NamePart"), UPB_VALUE_INIT_CONSTPTR(&msgs[19]), NULL},
};
static const upb_tabent intentries[14] = {

@ -54,20 +54,24 @@ char *upb_strdup2(const char *s, size_t len) {
}
// A type to represent the lookup key of either a strtable or an inttable.
typedef struct {
upb_tabkey key;
typedef union {
uintptr_t num;
struct {
const char *str;
size_t len;
} str;
} lookupkey_t;
static lookupkey_t strkey2(const char *str, size_t len) {
lookupkey_t k;
k.key.s.str = (char*)str;
k.key.s.length = len;
k.str.str = str;
k.str.len = len;
return k;
}
static lookupkey_t intkey(uintptr_t key) {
lookupkey_t k;
k.key = upb_intkey(key);
k.num = key;
return k;
}
@ -142,9 +146,11 @@ static bool lookup(const upb_table *t, lookupkey_t key, upb_value *v,
}
// The given key must not already exist in the table.
static void insert(upb_table *t, lookupkey_t key, upb_value val,
uint32_t hash, hashfunc_t *hashfunc, eqlfunc_t *eql) {
static void insert(upb_table *t, lookupkey_t key, upb_tabkey tabkey,
upb_value val, uint32_t hash,
hashfunc_t *hashfunc, eqlfunc_t *eql) {
UPB_UNUSED(eql);
UPB_UNUSED(key);
assert(findentry(t, key, hash, eql) == NULL);
assert(val.ctype == t->ctype);
t->count++;
@ -178,7 +184,7 @@ static void insert(upb_table *t, lookupkey_t key, upb_value val,
our_e->next = NULL;
}
}
our_e->key = key.key;
our_e->key = tabkey;
our_e->val = val.val;
assert(findentry(t, key, hash, eql) == our_e);
}
@ -197,10 +203,10 @@ static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
upb_tabent *move = (upb_tabent*)chain->next;
*chain = *move;
if (removed) *removed = move->key;
move->key.num = 0; // Make the slot empty.
move->key = 0; // Make the slot empty.
} else {
if (removed) *removed = chain->key;
chain->key.num = 0; // Make the slot empty.
chain->key = 0; // Make the slot empty.
}
return true;
} else {
@ -214,7 +220,7 @@ static bool rm(upb_table *t, lookupkey_t key, upb_value *val,
}
upb_tabent *rm = (upb_tabent*)chain->next;
if (removed) *removed = rm->key;
rm->key.num = 0;
rm->key = 0;
chain->next = rm->next;
t->count--;
return true;
@ -242,13 +248,24 @@ static size_t begin(const upb_table *t) {
// A simple "subclass" of upb_table that only adds a hash function for strings.
static upb_tabkey strcopy(lookupkey_t k2) {
char *str = malloc(k2.str.len + sizeof(uint32_t) + 1);
if (str == NULL) return 0;
memcpy(str, &k2.str.len, sizeof(uint32_t));
memcpy(str + sizeof(uint32_t), k2.str.str, k2.str.len + 1);
return (uintptr_t)str;
}
static uint32_t strhash(upb_tabkey key) {
return MurmurHash2(key.s.str, key.s.length, 0);
uint32_t len;
char *str = upb_tabstr(key, &len);
return MurmurHash2(str, len, 0);
}
static bool streql(upb_tabkey k1, lookupkey_t k2) {
return k1.s.length == k2.key.s.length &&
memcmp(k1.s.str, k2.key.s.str, k1.s.length) == 0;
uint32_t len;
char *str = upb_tabstr(k1, &len);
return len == k2.str.len && memcmp(str, k2.str.str, len) == 0;
}
bool upb_strtable_init(upb_strtable *t, upb_ctype_t ctype) {
@ -257,7 +274,7 @@ bool upb_strtable_init(upb_strtable *t, upb_ctype_t ctype) {
void upb_strtable_uninit(upb_strtable *t) {
for (size_t i = 0; i < upb_table_size(&t->t); i++)
free((void*)t->t.entries[i].key.s.str);
free((void*)t->t.entries[i].key);
uninit(&t->t);
}
@ -287,11 +304,12 @@ bool upb_strtable_insert2(upb_strtable *t, const char *k, size_t len,
return false;
}
}
if ((k = upb_strdup2(k, len)) == NULL) return false;
lookupkey_t key = strkey2(k, len);
uint32_t hash = MurmurHash2(key.key.s.str, key.key.s.length, 0);
insert(&t->t, key, v, hash, &strhash, &streql);
upb_tabkey tabkey = strcopy(key);
if (tabkey == 0) return false;
uint32_t hash = MurmurHash2(key.str.str, key.str.len, 0);
insert(&t->t, key, tabkey, v, hash, &strhash, &streql);
return true;
}
@ -306,7 +324,7 @@ bool upb_strtable_remove2(upb_strtable *t, const char *key, size_t len,
uint32_t hash = MurmurHash2(key, strlen(key), 0);
upb_tabkey tabkey;
if (rm(&t->t, strkey2(key, len), val, &tabkey, hash, &streql)) {
free((void*)tabkey.s.str);
free((void*)tabkey);
return true;
} else {
return false;
@ -335,12 +353,14 @@ bool upb_strtable_done(const upb_strtable_iter *i) {
const char *upb_strtable_iter_key(upb_strtable_iter *i) {
assert(!upb_strtable_done(i));
return str_tabent(i)->key.s.str;
return upb_tabstr(str_tabent(i)->key, NULL);
}
size_t upb_strtable_iter_keylength(upb_strtable_iter *i) {
assert(!upb_strtable_done(i));
return str_tabent(i)->key.s.length;
uint32_t len;
upb_tabstr(str_tabent(i)->key, &len);
return len;
}
upb_value upb_strtable_iter_value(const upb_strtable_iter *i) {
@ -365,10 +385,10 @@ bool upb_strtable_iter_isequal(const upb_strtable_iter *i1,
// For inttables we use a hybrid structure where small keys are kept in an
// array and large keys are put in the hash table.
static uint32_t inthash(upb_tabkey key) { return upb_inthash(key.num); }
static uint32_t inthash(upb_tabkey key) { return upb_inthash(key); }
static bool inteql(upb_tabkey k1, lookupkey_t k2) {
return k1.num == k2.key.num;
return k1 == k2.num;
}
static _upb_value *mutable_array(upb_inttable *t) {
@ -452,8 +472,8 @@ bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val) {
const upb_tabent *e = &t->t.entries[i];
upb_value v;
_upb_value_setval(&v, e->val, t->t.ctype);
uint32_t hash = upb_inthash(e->key.num);
insert(&new_table, intkey(e->key.num), v, hash, &inthash, &inteql);
uint32_t hash = upb_inthash(e->key);
insert(&new_table, intkey(e->key), e->key, v, hash, &inthash, &inteql);
}
assert(t->t.count == new_table.count);
@ -461,7 +481,7 @@ bool upb_inttable_insert(upb_inttable *t, uintptr_t key, upb_value val) {
uninit(&t->t);
t->t = new_table;
}
insert(&t->t, intkey(key), val, upb_inthash(key), &inthash, &inteql);
insert(&t->t, intkey(key), key, val, upb_inthash(key), &inthash, &inteql);
}
check(t);
return true;
@ -629,7 +649,7 @@ bool upb_inttable_done(const upb_inttable_iter *i) {
uintptr_t upb_inttable_iter_key(const upb_inttable_iter *i) {
assert(!upb_inttable_done(i));
return i->array_part ? i->index : int_tabent(i)->key.num;
return i->array_part ? i->index : int_tabent(i)->key;
}
upb_value upb_inttable_iter_value(const upb_inttable_iter *i) {

@ -152,33 +152,46 @@ FUNCS(fptr, fptr, upb_func*, UPB_CTYPE_FPTR);
/* upb_table ******************************************************************/
typedef union {
uintptr_t num;
struct {
// We own this. NULL-terminated but may also contain binary data; see
// explicit length below.
// TODO: move the length to the start of the string in order to reduce
// tabkey's size (to one machine word) in a way that supports static
// initialization.
const char *str;
size_t length;
} s;
} upb_tabkey;
#define UPB_TABKEY_NUM(n) {n}
#ifdef UPB_C99
// Given that |s| is a string literal, sizeof(s) gives us a
// compile-time-constant strlen(). We must ensure that this works for static
// data initializers.
#define UPB_TABKEY_STR(strval) { .s = { .str = strval, \
.length = sizeof(strval) - 1 } }
#endif
// TODO(haberman): C++
#define UPB_TABKEY_NONE {0}
#define UPB_TABKEY_NUM(n) n
#define UPB_TABKEY_NONE 0
// The preprocessor isn't quite powerful enough to turn the compile-time string
// length into a byte-wise string representation, so code generation needs to
// help it along.
//
// "len1" is the low byte and len4 is the high byte. For big endian we'll need
// to define a version of this that flips it around.
#define UPB_TABKEY_STR(len1, len2, len3, len4, strval) \
(uintptr_t)(len1 len2 len3 len4 strval)
// Either:
// 1. an actual integer key, or
// 2. a pointer to a string prefixed by its uint32_t length, owned by us.
//
// ...depending on whether this is a string table or an int table. We would
// make this a union of those two types, but C89 doesn't support statically
// initializing a non-first union member.
typedef uintptr_t upb_tabkey;
// Ideally we could use a structure like this instead of the memcpy() calls:
//
// typedef struct {
// uint32_t len;
// char data[1]; // Allocate to correct length.
// } upb_tabstr;
//
// But unfortuantely in C89 there is no way to statically initialize such a
// thing. So instead of memcpy() the length in and out of the string.
UPB_INLINE char *upb_tabstr(upb_tabkey key, uint32_t *len) {
char* mem = (char*)key;
if (len) memcpy(len, mem, sizeof(*len));
return mem + sizeof(*len);
}
typedef struct _upb_tabent {
upb_tabkey key;
_upb_value val;
// Internal chaining. This is const so we can create static initializers for
// tables. We cast away const sometimes, but *only* when the containing
// upb_table is known to be non-const. This requires a bit of care, but
@ -235,16 +248,14 @@ UPB_INLINE size_t upb_table_size(const upb_table *t) {
// Internal-only functions, in .h file only out of necessity.
UPB_INLINE bool upb_tabent_isempty(const upb_tabent *e) {
return e->key.num == 0;
return e->key == 0;
}
// Used by some of the unit tests for generic hashing functionality.
uint32_t MurmurHash2(const void * key, size_t len, uint32_t seed);
UPB_INLINE upb_tabkey upb_intkey(uintptr_t key) {
upb_tabkey k;
k.num = key;
return k;
UPB_INLINE uintptr_t upb_intkey(uintptr_t key) {
return key;
}
UPB_INLINE uint32_t upb_inthash(uintptr_t key) {
@ -350,7 +361,7 @@ UPB_INLINE bool upb_inttable_lookup32(const upb_inttable *t, uint32_t key,
const upb_tabent *e;
if (t->t.entries == NULL) return false;
for (e = upb_getentry(&t->t, upb_inthash(key)); true; e = e->next) {
if ((uint32_t)e->key.num == key) {
if ((uint32_t)e->key == key) {
_upb_value_setval(v, e->val, t->t.ctype);
return true;
}

Loading…
Cancel
Save